Search in sources :

Example 1 with ConfigurationManager

use of com.biglybt.core.config.impl.ConfigurationManager in project BiglyBT by BiglySoftware.

the class TableViewSWT_TabsCommon method createSashForm.

public Composite createSashForm(final Composite composite) {
    if (!tv.isTabViewsEnabled()) {
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    SelectedContentManager.addCurrentlySelectedContentListener(this);
    ConfigurationManager configMan = ConfigurationManager.getInstance();
    int iNumViews = 0;
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        if (pluginUI != null) {
            iNumViews += pluginUI.getViewListeners(tv.getTableID()).length;
        }
    }
    if (iNumViews == 0) {
        tableComposite = tv.createMainPanel(composite);
        return tableComposite;
    }
    final String props_prefix = tv.getTableID() + "." + tv.getPropertiesPrefix();
    FormData formData;
    final Composite form = new Composite(composite, SWT.NONE);
    FormLayout flayout = new FormLayout();
    flayout.marginHeight = 0;
    flayout.marginWidth = 0;
    form.setLayout(flayout);
    GridData gridData;
    gridData = new GridData(GridData.FILL_BOTH);
    form.setLayoutData(gridData);
    // Create them in reverse order, so we can have the table auto-grow, and
    // set the tabFolder's height manually
    cTabsHolder = new Composite(form, SWT.NONE);
    tabbedMDI = uiFunctions.createTabbedMDI(cTabsHolder, props_prefix);
    tabbedMDI.setMaximizeVisible(true);
    tabbedMDI.setMinimizeVisible(true);
    tabbedMDI.setTabbedMdiMaximizeListener(new TabbedMdiMaximizeListener() {

        @Override
        public void maximizePressed() {
            TableView tvToUse = tvOverride == null ? tv : tvOverride;
            Object[] ds = tvToUse.getSelectedDataSources(true);
            if (ds.length == 1 && ds[0] instanceof DownloadManager) {
                UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                if (uiFunctions != null) {
                    uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, ds);
                }
            }
        }
    });
    final int SASH_WIDTH = 5;
    sash = Utils.createSash(form, SASH_WIDTH);
    tableComposite = tv.createMainPanel(form);
    Composite cFixLayout = tableComposite;
    while (cFixLayout != null && cFixLayout.getParent() != form) {
        cFixLayout = cFixLayout.getParent();
    }
    if (cFixLayout == null) {
        cFixLayout = tableComposite;
    }
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    cFixLayout.setLayout(layout);
    // FormData for Folder
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(100, 0);
    int iSplitAt = configMan.getIntParameter(props_prefix + ".SplitAt", 3000);
    // Was stored at whole
    if (iSplitAt < 100) {
        iSplitAt *= 100;
    }
    // pct is % bottom
    double pct = iSplitAt / 10000.0;
    if (pct < 0.03) {
        pct = 0.03;
    } else if (pct > 0.97) {
        pct = 0.97;
    }
    // height will be set on first resize call
    sash.setData("PCT", new Double(pct));
    cTabsHolder.setLayout(new FormLayout());
    fdHeightChanger = formData;
    cTabsHolder.setLayoutData(formData);
    // FormData for Sash
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.bottom = new FormAttachment(cTabsHolder);
    formData.height = SASH_WIDTH;
    sash.setLayoutData(formData);
    // FormData for table Composite
    formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(sash);
    cFixLayout.setLayoutData(formData);
    // Listeners to size the folder
    sash.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final boolean FASTDRAG = true;
            if (FASTDRAG && e.detail == SWT.DRAG) {
                return;
            }
            Rectangle area = form.getClientArea();
            int height = area.height - e.y - e.height;
            if (!Constants.isWindows) {
                height -= SASH_WIDTH;
            }
            if (area.height - height < 100) {
                height = area.height - 100;
            }
            if (height < 0) {
                height = 0;
            }
            fdHeightChanger.height = height;
            Double l = new Double((double) height / area.height);
            sash.setData("PCT", l);
            if (e.detail != SWT.DRAG) {
                ConfigurationManager configMan = ConfigurationManager.getInstance();
                configMan.setParameter(props_prefix + ".SplitAt", (int) (l.doubleValue() * 10000));
            }
            form.layout();
            // sometimes sash cheese is left
            cTabsHolder.redraw();
        }
    });
    buildFolder(form, props_prefix);
    return form;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) DownloadManager(com.biglybt.core.download.DownloadManager) TabbedMdiMaximizeListener(com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener) UIFunctions(com.biglybt.ui.UIFunctions) SelectionEvent(org.eclipse.swt.events.SelectionEvent) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) COConfigurationManager(com.biglybt.core.config.COConfigurationManager) ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager) TableView(com.biglybt.ui.common.table.TableView)

Example 2 with ConfigurationManager

use of com.biglybt.core.config.impl.ConfigurationManager in project BiglyBT by BiglySoftware.

the class FileLogging method reloadLogToFileParam.

/**
 */
protected void reloadLogToFileParam() {
    final ConfigurationManager config = ConfigurationManager.getInstance();
    boolean bNewLogToFile = System.getProperty(SystemProperties.SYSPROP_OVERRIDELOG) != null || config.getBooleanParameter(CFG_ENABLELOGTOFILE);
    if (bNewLogToFile != bLogToFile) {
        bLogToFile = bNewLogToFile;
        if (bLogToFile)
            Logger.addListener(this);
        else {
            Logger.removeListener(this);
            synchronized (Logger.class) {
                // close existing file
                checkAndSwapLog();
            }
        }
    }
}
Also used : ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager)

Example 3 with ConfigurationManager

use of com.biglybt.core.config.impl.ConfigurationManager in project BiglyBT by BiglySoftware.

the class FileLogging method initialize.

public void initialize() {
    // Shorten from COConfigurationManager To make code more readable
    final ConfigurationManager config = ConfigurationManager.getInstance();
    boolean overrideLog = System.getProperty(SystemProperties.SYSPROP_OVERRIDELOG) != null;
    for (int i = 0; i < ignoredComponents.length; i++) {
        ignoredComponents[i] = new ArrayList();
    }
    if (!overrideLog) {
        config.addListener(new COConfigurationListener() {

            @Override
            public void configurationSaved() {
                checkLoggingConfig();
            }
        });
    }
    checkLoggingConfig();
    config.addParameterListener(CFG_ENABLELOGTOFILE, new ParameterListener() {

        @Override
        public void parameterChanged(String parameterName) {
            FileLogging.this.reloadLogToFileParam();
        }
    });
}
Also used : COConfigurationListener(com.biglybt.core.config.COConfigurationListener) ArrayList(java.util.ArrayList) ParameterListener(com.biglybt.core.config.ParameterListener) ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager)

Example 4 with ConfigurationManager

use of com.biglybt.core.config.impl.ConfigurationManager in project BiglyBT by BiglySoftware.

the class LoggerImpl method init.

/**
 * Must be seperate from constructor, because the code may call a Logger.*
 * method, which requires a loggerImpl to be not null.
 */
public void init() {
    // temporarily set to true, to log any errors between now and setting
    // bEnabled properly.
    bEventLoggingEnabled = true;
    // Shorten from COConfigurationManager To make code more readable
    final ConfigurationManager config = ConfigurationManager.getInstance();
    boolean overrideLog = System.getProperty(SystemProperties.SYSPROP_OVERRIDELOG) != null;
    if (overrideLog) {
        bEventLoggingEnabled = true;
    } else {
        bEventLoggingEnabled = config.getBooleanParameter("Logger.Enabled");
        config.addParameterListener("Logger.Enabled", new ParameterListener() {

            @Override
            public void parameterChanged(String parameterName) {
                bEventLoggingEnabled = config.getBooleanParameter("Logger.Enabled");
            }
        });
    }
}
Also used : ParameterListener(com.biglybt.core.config.ParameterListener) ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager)

Example 5 with ConfigurationManager

use of com.biglybt.core.config.impl.ConfigurationManager in project BiglyBT by BiglySoftware.

the class PluginConfigSourceImpl method registerParameter.

// Not exposed in the plugin API...
public void registerParameter(String full_param) {
    shouldBeInitialised(true);
    if (!this.params_monitored.add(full_param)) {
        return;
    }
    ConfigurationManager config = ConfigurationManager.getInstance();
    config.registerTransientParameter(full_param);
    config.addParameterListener(full_param, this);
    if (this.migrate_settings && COConfigurationManager.hasParameter(full_param, true)) {
        this.parameterChanged(full_param);
    }
}
Also used : ConfigurationManager(com.biglybt.core.config.impl.ConfigurationManager) COConfigurationManager(com.biglybt.core.config.COConfigurationManager)

Aggregations

ConfigurationManager (com.biglybt.core.config.impl.ConfigurationManager)10 COConfigurationManager (com.biglybt.core.config.COConfigurationManager)5 ParameterListener (com.biglybt.core.config.ParameterListener)3 Composite (org.eclipse.swt.widgets.Composite)2 COConfigurationListener (com.biglybt.core.config.COConfigurationListener)1 DownloadManager (com.biglybt.core.download.DownloadManager)1 AERunnable (com.biglybt.core.util.AERunnable)1 UIFunctions (com.biglybt.ui.UIFunctions)1 TableView (com.biglybt.ui.common.table.TableView)1 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)1 TabbedMdiMaximizeListener (com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener)1 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Color (org.eclipse.swt.graphics.Color)1 RGB (org.eclipse.swt.graphics.RGB)1