Search in sources :

Example 21 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SubscriptionWizard method populateFooter.

private void populateFooter(Composite footer) {
    yesButton = new Button(footer, SWT.PUSH);
    yesButton.setText(MessageText.getString("Button.yes"));
    yesButton.setFont(boldFont);
    addButton = new Button(footer, SWT.PUSH);
    addButton.setText(MessageText.getString("Button.add"));
    addButton.setFont(boldFont);
    saveButton = new Button(footer, SWT.PUSH);
    saveButton.setText(MessageText.getString("Button.save"));
    saveButton.setEnabled(false);
    saveButton.setFont(boldFont);
    searchButton = new Button(footer, SWT.PUSH);
    searchButton.setText(MessageText.getString("Button.search"));
    searchButton.setFont(boldFont);
    cancelButton = new Button(footer, SWT.PUSH);
    // cancelButton.setText(MessageText.getString("Button.cancel"));
    createButton = new Button(footer, SWT.PUSH);
    createButton.setText(MessageText.getString("Button.createNewSubscription"));
    availableButton = new Button(footer, SWT.PUSH);
    availableButton.setText(MessageText.getString("Button.availableSubscriptions"));
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    layout.spacing = 5;
    footer.setLayout(layout);
    FormData data;
    data = new FormData();
    data.right = new FormAttachment(100);
    data.width = 100;
    yesButton.setLayoutData(data);
    addButton.setLayoutData(data);
    searchButton.setLayoutData(data);
    data = new FormData();
    data.right = new FormAttachment(100);
    data.width = 100;
    saveButton.setLayoutData(data);
    data = new FormData();
    data.right = new FormAttachment(saveButton);
    data.width = 100;
    cancelButton.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(0);
    data.width = 175;
    createButton.setLayoutData(data);
    availableButton.setLayoutData(data);
    yesButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            COConfigurationManager.setParameter("subscriptions.opted_in", true);
            COConfigurationManager.save();
            setMode(MODE_SUBSCRIBE);
        }
    });
    createButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event arg0) {
            setMode(MODE_CREATE_SEARCH);
        }
    });
    availableButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event arg0) {
            setDefaultAvailableMode();
        }
    });
    cancelButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event arg0) {
            shell.close();
        }
    });
    rssSaveListener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            try {
                String url_str = feedUrl.getText();
                URL url = new URL(url_str);
                Map user_data = new HashMap();
                user_data.put(SubscriptionManagerUI.SUB_EDIT_MODE_KEY, Boolean.TRUE);
                boolean anonymous = anonCheck.getSelection();
                String subs_name = subsName.getText().trim();
                if (subs_name.length() == 0) {
                    subs_name = url_str;
                }
                Subscription subRSS = SubscriptionManagerFactory.getSingleton().createRSS(subs_name, url, SubscriptionHistory.DEFAULT_CHECK_INTERVAL_MINS, anonymous, user_data);
                if (anonymous) {
                    subRSS.getHistory().setDownloadNetworks(new String[] { AENetworkClassifier.AT_I2P });
                }
                shell.close();
                final String key = "Subscription_" + ByteFormatter.encodeString(subRSS.getPublicKey());
                MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                mdi.showEntryByID(key);
            } catch (Throwable e) {
                Utils.reportError(e);
            }
        }
    };
    saveButton.addListener(SWT.Selection, rssSaveListener);
    addButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            Subscription subscription = (Subscription) addButton.getData("subscription");
            if (subscription != null) {
                subscription.setSubscribed(true);
                subscription.requestAttention();
                shell.close();
            }
        }
    });
    searchListener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            UIFunctionsManager.getUIFunctions().doSearch(searchInput.getText(), true);
            shell.close();
        }
    };
    searchButton.addListener(SWT.Selection, searchListener);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) TableCellAddedListener(com.biglybt.pif.ui.tables.TableCellAddedListener) TableSelectionListener(com.biglybt.ui.common.table.TableSelectionListener) TableCellSWTPaintListener(com.biglybt.ui.swt.views.table.TableCellSWTPaintListener) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) TableCellRefreshListener(com.biglybt.pif.ui.tables.TableCellRefreshListener) Listener(org.eclipse.swt.widgets.Listener) CoreRunningListener(com.biglybt.core.CoreRunningListener) HashMap(java.util.HashMap) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) URL(java.net.URL) Button(org.eclipse.swt.widgets.Button) Event(org.eclipse.swt.widgets.Event) Subscription(com.biglybt.core.subs.Subscription) Map(java.util.Map) HashMap(java.util.HashMap) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 22 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SubscriptionsView method initialize.

private void initialize(Composite parent) {
    viewComposite = new Composite(parent, SWT.NONE);
    viewComposite.setLayout(new FormLayout());
    TableColumnCore[] columns = new TableColumnCore[] { new ColumnSubscriptionNew(TABLE_ID), new ColumnSubscriptionName(TABLE_ID), new ColumnSubscriptionNbNewResults(TABLE_ID), new ColumnSubscriptionNbResults(TABLE_ID), new ColumnSubscriptionMaxResults(TABLE_ID), new ColumnSubscriptionLastChecked(TABLE_ID), new ColumnSubscriptionSubscribers(TABLE_ID), new ColumnSubscriptionEnabled(TABLE_ID), new ColumnSubscriptionAutoDownload(TABLE_ID), new ColumnSubscriptionCategory(TABLE_ID), new ColumnSubscriptionTag(TABLE_ID), new ColumnSubscriptionParent(TABLE_ID), new ColumnSubscriptionError(TABLE_ID) };
    TableColumnManager tcm = TableColumnManager.getInstance();
    tcm.setDefaultColumnNames(TABLE_ID, new String[] { ColumnSubscriptionNew.COLUMN_ID, ColumnSubscriptionName.COLUMN_ID, ColumnSubscriptionNbNewResults.COLUMN_ID, ColumnSubscriptionNbResults.COLUMN_ID, ColumnSubscriptionAutoDownload.COLUMN_ID });
    view = TableViewFactory.createTableViewSWT(Subscription.class, TABLE_ID, TABLE_ID, columns, "name", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    view.addLifeCycleListener(new TableLifeCycleListener() {

        @Override
        public void tableLifeCycleEventOccurred(TableView tv, int eventType, Map<String, Object> data) {
            switch(eventType) {
                case EVENT_TABLELIFECYCLE_INITIALIZED:
                    SubscriptionManagerFactory.getSingleton().addListener(SubscriptionsView.this);
                    view.addDataSources(SubscriptionManagerFactory.getSingleton().getSubscriptions(true));
                    break;
                case EVENT_TABLELIFECYCLE_DESTROYED:
                    SubscriptionManagerFactory.getSingleton().removeListener(SubscriptionsView.this);
                    break;
            }
        }
    });
    view.addSelectionListener(new TableSelectionAdapter() {

        PluginInterface pi = PluginInitializer.getDefaultInterface();

        UIManager uim = pi.getUIManager();

        MenuManager menu_manager = uim.getMenuManager();

        TableManager table_manager = uim.getTableManager();

        ArrayList<TableContextMenuItem> menu_items = new ArrayList<>();

        SubscriptionManagerUI.MenuCreator menu_creator = new SubscriptionManagerUI.MenuCreator() {

            @Override
            public com.biglybt.pif.ui.menus.MenuItem createMenu(String resource_id) {
                TableContextMenuItem menu = table_manager.addContextMenuItem(TABLE_ID, resource_id);
                menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
                menu_items.add(menu);
                return (menu);
            }

            @Override
            public void refreshView() {
            }
        };

        @Override
        public void defaultSelected(TableRowCore[] rows, int stateMask) {
            if (rows.length == 1) {
                TableRowCore row = rows[0];
                Subscription sub = (Subscription) row.getDataSource();
                if (sub == null) {
                    return;
                }
                if (sub.isSearchTemplate()) {
                    try {
                        VuzeFile vf = sub.getSearchTemplateVuzeFile();
                        if (vf != null) {
                            sub.setSubscribed(true);
                            VuzeFileHandler.getSingleton().handleFiles(new VuzeFile[] { vf }, VuzeFileComponent.COMP_TYPE_NONE);
                            for (VuzeFileComponent comp : vf.getComponents()) {
                                Engine engine = (Engine) comp.getData(Engine.VUZE_FILE_COMPONENT_ENGINE_KEY);
                                if (engine != null && (engine.getSelectionState() == Engine.SEL_STATE_DESELECTED || engine.getSelectionState() == Engine.SEL_STATE_FORCE_DESELECTED)) {
                                    engine.setSelectionState(Engine.SEL_STATE_MANUAL_SELECTED);
                                }
                            }
                        }
                    } catch (Throwable e) {
                        Debug.out(e);
                    }
                } else {
                    String key = "Subscription_" + ByteFormatter.encodeString(sub.getPublicKey());
                    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
                    if (mdi != null) {
                        mdi.showEntryByID(key);
                    }
                }
            }
        }

        @Override
        public void selected(TableRowCore[] rows) {
            rows = view.getSelectedRows();
            ISelectedContent[] sels = new ISelectedContent[rows.length];
            java.util.List<Subscription> subs = new ArrayList<>();
            for (int i = 0; i < rows.length; i++) {
                Subscription sub = (Subscription) rows[i].getDataSource();
                sels[i] = new SubscriptionSelectedContent(sub);
                if (sub != null) {
                    subs.add(sub);
                }
            }
            SelectedContentManager.changeCurrentlySelectedContent(view.getTableID(), sels, view);
            for (TableContextMenuItem mi : menu_items) {
                mi.remove();
            }
            if (subs.size() > 0) {
                SubscriptionManagerUI.createMenus(menu_manager, menu_creator, subs.toArray(new Subscription[0]));
            }
        }
    }, false);
    view.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent event) {
        }

        @Override
        public void keyReleased(KeyEvent event) {
            if (event.keyCode == SWT.DEL) {
                removeSelected();
            }
        }
    });
    view.setRowDefaultHeightEM(1.4f);
    view.initialize(viewComposite);
    final Composite composite = new Composite(viewComposite, SWT.BORDER);
    composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
    composite.setBackground(ColorCache.getColor(composite.getDisplay(), "#F1F9F8"));
    Font font = composite.getFont();
    FontData[] fDatas = font.getFontData();
    for (int i = 0; i < fDatas.length; i++) {
        fDatas[i].setHeight(150 * fDatas[i].getHeight() / 100);
        if (Constants.isWindows) {
            fDatas[i].setStyle(SWT.BOLD);
        }
    }
    textFont1 = new Font(composite.getDisplay(), fDatas);
    fDatas = font.getFontData();
    for (int i = 0; i < fDatas.length; i++) {
        fDatas[i].setHeight(120 * fDatas[i].getHeight() / 100);
    }
    textFont2 = new Font(composite.getDisplay(), fDatas);
    Label preText = new Label(composite, SWT.NONE);
    preText.setForeground(ColorCache.getColor(composite.getDisplay(), "#6D6F6E"));
    preText.setFont(textFont1);
    preText.setText(MessageText.getString("subscriptions.view.help.1"));
    Label image = new Label(composite, SWT.NONE);
    ImageLoader.getInstance().setLabelImage(image, "btn_rss_add");
    Link postText = new Link(composite, SWT.NONE);
    postText.setForeground(ColorCache.getColor(composite.getDisplay(), "#6D6F6E"));
    postText.setFont(textFont2);
    postText.setText(MessageText.getString("subscriptions.view.help.2"));
    postText.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (event.text != null && (event.text.startsWith("http://") || event.text.startsWith("https://"))) {
                Utils.launch(event.text);
            }
        }
    });
    Label close = new Label(composite, SWT.NONE);
    ImageLoader.getInstance().setLabelImage(close, "image.dismissX");
    close.setCursor(composite.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
    close.addListener(SWT.MouseUp, new Listener() {

        @Override
        public void handleEvent(Event arg0) {
            COConfigurationManager.setParameter("subscriptions.view.showhelp", false);
            composite.setVisible(false);
            FormData data = (FormData) view.getComposite().getLayoutData();
            data.bottom = new FormAttachment(100, 0);
            viewComposite.layout(true);
        }
    });
    FormLayout layout = new FormLayout();
    composite.setLayout(layout);
    FormData data;
    data = new FormData();
    data.left = new FormAttachment(0, 15);
    data.top = new FormAttachment(0, 20);
    data.bottom = new FormAttachment(postText, -5);
    preText.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(preText, 5);
    data.top = new FormAttachment(preText, 0, SWT.CENTER);
    image.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(preText, 0, SWT.LEFT);
    // data.top = new FormAttachment(preText,5);
    data.bottom = new FormAttachment(100, -20);
    postText.setLayoutData(data);
    data = new FormData();
    data.right = new FormAttachment(100, -10);
    data.top = new FormAttachment(0, 10);
    close.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(composite, 0);
    viewComposite.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    composite.setLayoutData(data);
    COConfigurationManager.setBooleanDefault("subscriptions.view.showhelp", true);
    if (!COConfigurationManager.getBooleanParameter("subscriptions.view.showhelp")) {
        composite.setVisible(false);
        data = (FormData) viewComposite.getLayoutData();
        data.bottom = new FormAttachment(100, 0);
        viewComposite.layout(true);
    }
}
Also used : ArrayList(java.util.ArrayList) UIManager(com.biglybt.pif.ui.UIManager) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) ArrayList(java.util.ArrayList) Subscription(com.biglybt.core.subs.Subscription) Engine(com.biglybt.core.metasearch.Engine) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) FontData(org.eclipse.swt.graphics.FontData) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) SubscriptionManagerListener(com.biglybt.core.subs.SubscriptionManagerListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) UISWTViewCoreEventListener(com.biglybt.ui.swt.pifimpl.UISWTViewCoreEventListener) KeyListener(org.eclipse.swt.events.KeyListener) VuzeFileComponent(com.biglybt.core.vuzefile.VuzeFileComponent) TableContextMenuItem(com.biglybt.pif.ui.tables.TableContextMenuItem) Font(org.eclipse.swt.graphics.Font) KeyEvent(org.eclipse.swt.events.KeyEvent) VuzeFile(com.biglybt.core.vuzefile.VuzeFile) TableManager(com.biglybt.pif.ui.tables.TableManager) com.biglybt.pif.ui.menus(com.biglybt.pif.ui.menus) FormLayout(org.eclipse.swt.layout.FormLayout) PluginInterface(com.biglybt.pif.PluginInterface) KeyEvent(org.eclipse.swt.events.KeyEvent) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Example 23 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SBC_ActivityTableView method setupSidebarEntry.

public static void setupSidebarEntry(final MultipleDocumentInterface mdi) {
    // Put TitleInfo in another class
    final ViewTitleInfo titleInfoActivityView = new ViewTitleInfo() {

        boolean had_unviewed = false;

        @Override
        public Object getTitleInfoProperty(int propertyID) {
            if (propertyID == TITLE_INDICATOR_TEXT) {
                int num_unread = 0;
                int num_unviewed = 0;
                List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
                for (ActivitiesEntry entry : allEntries) {
                    if (!entry.isRead()) {
                        num_unread++;
                    }
                    if (!entry.getViewed()) {
                        num_unviewed++;
                    }
                }
                if (num_unread == 0) {
                    num_unviewed = 0;
                }
                boolean has_unviewed = num_unviewed > 0;
                if (has_unviewed != had_unviewed) {
                    if (has_unviewed) {
                        MdiEntry parent = mdi.getEntry(MultipleDocumentInterface.SIDEBAR_HEADER_VUZE);
                        if (parent != null && !parent.isExpanded()) {
                            parent.setExpanded(true);
                        }
                    }
                    had_unviewed = has_unviewed;
                }
                if (num_unviewed > 0) {
                    return (String.valueOf(num_unviewed) + (num_unread == 0 ? "" : (":" + num_unread)));
                } else if (num_unread > 0) {
                    return (String.valueOf(num_unread));
                }
                return null;
            } else if (propertyID == TITLE_IMAGEID) {
                return "image.sidebar.activity";
            } else if (propertyID == TITLE_INDICATOR_COLOR) {
                boolean has_unread = false;
                boolean has_unviewed = false;
                List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
                for (ActivitiesEntry entry : allEntries) {
                    if (!entry.isRead()) {
                        has_unread = true;
                    }
                    if (!entry.getViewed()) {
                        has_unviewed = true;
                    }
                }
                if (has_unread && has_unviewed) {
                    return (COLOR_UNVIEWED_ENTRIES);
                }
            }
            return null;
        }
    };
    activitiesListener = new ActivitiesListener() {

        @Override
        public void vuzeNewsEntryChanged(ActivitiesEntry entry) {
            refresh();
        }

        @Override
        public void vuzeNewsEntriesRemoved(ActivitiesEntry[] entries) {
            refresh();
        }

        @Override
        public void vuzeNewsEntriesAdded(ActivitiesEntry[] entries) {
            refresh();
        }

        private void refresh() {
            ViewTitleInfoManager.refreshTitleInfo(titleInfoActivityView);
            if (mdi_entry != null) {
                mdi_entry.redraw();
            }
        }
    };
    ActivitiesManager.addListener(activitiesListener);
    MdiEntryCreationListener creationListener = new MdiEntryCreationListener() {

        @Override
        public MdiEntry createMDiEntry(String id) {
            mdi_entry = mdi.createEntryFromSkinRef(MultipleDocumentInterface.SIDEBAR_HEADER_VUZE, MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, "activity", "{sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES + "}", titleInfoActivityView, null, false, null);
            return (mdi_entry);
        }
    };
    mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, creationListener);
    mdi.registerEntry("activities", creationListener);
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    final MenuItem menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_ACTIVITIES, "v3.activity.button.readall");
    menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItem.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            List<ActivitiesEntry> allEntries = ActivitiesManager.getAllEntries();
            for (ActivitiesEntry entry : allEntries) {
                entry.setRead(true);
            }
        }
    });
    mdi.addListener(new MdiListener() {

        @Override
        public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
        }

        @Override
        public void mdiDisposed(MultipleDocumentInterface mdi) {
            if (activitiesListener != null) {
                ActivitiesManager.removeListener(activitiesListener);
                activitiesListener = null;
            }
            menuItem.remove();
        }
    });
}
Also used : ActivitiesListener(com.biglybt.activities.ActivitiesListener) MdiListener(com.biglybt.ui.mdi.MdiListener) MdiEntryCreationListener(com.biglybt.ui.mdi.MdiEntryCreationListener) PluginInterface(com.biglybt.pif.PluginInterface) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) ActivitiesEntry(com.biglybt.activities.ActivitiesEntry) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MenuManager(com.biglybt.pif.ui.menus.MenuManager) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) ArrayList(java.util.ArrayList) List(java.util.List) ViewTitleInfo(com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)

Example 24 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SBC_ActivityView method setViewMode.

public void setViewMode(int viewMode, boolean save) {
    if (viewMode >= modeViewIDs.length || viewMode < 0) {
        viewMode = MODE_DEFAULT;
    }
    if (viewMode == this.viewMode) {
        return;
    }
    int oldViewMode = this.viewMode;
    this.viewMode = viewMode;
    soListArea = getSkinObject(ID + "-area");
    soListArea.getControl().setData("ViewMode", new Long(viewMode));
    if (oldViewMode >= 0 && oldViewMode < modeViewIDs.length) {
        SWTSkinObject soOldViewArea = getSkinObject(modeViewIDs[oldViewMode]);
        if (soOldViewArea != null) {
            soOldViewArea.setVisible(false);
        }
    }
    SWTSkinObject soViewArea = getSkinObject(modeViewIDs[viewMode]);
    if (soViewArea == null) {
        soViewArea = skin.createSkinObject(modeIDs[viewMode], modeIDs[viewMode], soListArea);
        skin.layout();
        soViewArea.setVisible(true);
        soViewArea.getControl().setLayoutData(Utils.getFilledFormData());
    } else {
        soViewArea.setVisible(true);
    }
    if (btnSmallTable != null) {
        btnSmallTable.getSkinObject().switchSuffix(viewMode == MODE_SMALLTABLE ? "-selected" : "");
    }
    if (btnBigTable != null) {
        btnBigTable.getSkinObject().switchSuffix(viewMode == MODE_BIGTABLE ? "-selected" : "");
    }
    if (save) {
        COConfigurationManager.setParameter(ID + ".viewmode", viewMode);
    }
    MultipleDocumentInterface mdi = UIFunctionsManager.getUIFunctions().getMDI();
    MdiEntry entry = mdi.getEntry(SideBar.SIDEBAR_SECTION_ACTIVITIES);
    if (entry != null) {
        entry.setLogID(SideBar.SIDEBAR_SECTION_ACTIVITIES + "-" + viewMode);
    }
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Example 25 with MultipleDocumentInterface

use of com.biglybt.ui.mdi.MultipleDocumentInterface in project BiglyBT by BiglySoftware.

the class SBC_GenericBrowsePage method skinObjectInitialShow.

@Override
public Object skinObjectInitialShow(SWTSkinObject skinObject, Object params) {
    Object creationParams = skinObject.getData("CreationParams");
    browserSkinObject = SWTSkinUtils.findBrowserSO(soMain);
    final MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
    if (mdi != null) {
        entry = mdi.getEntryBySkinView(this);
        if (entry != null) {
            vitalityImage = entry.addVitalityImage("image.sidebar.vitality.dots");
            vitalityImage.setVisible(false);
            mdi.addListener(new MdiListener() {

                long lastSelect = 0;

                @Override
                public void mdiEntrySelected(MdiEntry newEntry, MdiEntry oldEntry) {
                    if (entry == newEntry) {
                        if (entry == oldEntry) {
                            if (lastSelect < SystemTime.getOffsetTime(-1000)) {
                                if (browserSkinObject != null) {
                                    browserSkinObject.restart();
                                }
                            }
                        } else {
                            lastSelect = SystemTime.getCurrentTime();
                        }
                    }
                }

                @Override
                public void mdiDisposed(MultipleDocumentInterface mdi) {
                }
            });
        }
    }
    browserSkinObject.addListener(new SWTSkinObjectListener() {

        @Override
        public Object eventOccured(SWTSkinObject skinObject, int eventType, Object params) {
            if (eventType == EVENT_SHOW) {
                browserSkinObject.removeListener(this);
                browserSkinObject.addListener(new BrowserContext.loadingListener() {

                    @Override
                    public void browserLoadingChanged(boolean loading, String url) {
                        if (vitalityImage != null) {
                            vitalityImage.setVisible(loading);
                        }
                    }
                });
            } else if (eventType == EVENT_DATASOURCE_CHANGED) {
                if (params instanceof String) {
                    browserSkinObject.setURL((String) params);
                }
            }
            return null;
        }
    });
    openURL();
    return null;
}
Also used : SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MdiListener(com.biglybt.ui.mdi.MdiListener) MdiEntry(com.biglybt.ui.mdi.MdiEntry) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) SWTSkinObjectListener(com.biglybt.ui.swt.skin.SWTSkinObjectListener) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface)

Aggregations

MultipleDocumentInterface (com.biglybt.ui.mdi.MultipleDocumentInterface)27 MdiEntry (com.biglybt.ui.mdi.MdiEntry)15 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)6 PluginInterface (com.biglybt.pif.PluginInterface)5 Point (org.eclipse.swt.graphics.Point)5 ParameterListener (com.biglybt.core.config.ParameterListener)4 UIManager (com.biglybt.pif.ui.UIManager)4 MdiListener (com.biglybt.ui.mdi.MdiListener)4 ArrayList (java.util.ArrayList)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 CoreRunningListener (com.biglybt.core.CoreRunningListener)3 Subscription (com.biglybt.core.subs.Subscription)3 BaseMdiEntry (com.biglybt.ui.swt.mdi.BaseMdiEntry)3 GlobalManager (com.biglybt.core.global.GlobalManager)2 LogEvent (com.biglybt.core.logging.LogEvent)2 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)2 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)2 UIFunctions (com.biglybt.ui.UIFunctions)2