Package com.aelitis.azureus.ui.common.table.impl

Examples of com.aelitis.azureus.ui.common.table.impl.TableColumnManager


  }

  private void initializeColumnDefs() {
    // XXX Adding Columns only has to be done once per TableID. 
    // Doing it more than once won't harm anything, but it's a waste.
    TableColumnManager tcManager = TableColumnManager.getInstance();

    if (basicItems != null) {
      if (tcManager.getTableColumnCount(sTableID) != basicItems.length) {
        tcManager.addColumns(basicItems);
      }
      basicItems = null;
    }

    tableColumns = tcManager.getAllTableColumnCoreAsArray(classPluginDataSourceType,
        sTableID);

    // fixup order
    tcManager.ensureIntegrety(sTableID);
  }
View Full Code Here


      }
      case UIManagerEvent.ET_REGISTER_COLUMN:{
       
        Object[] params = (Object[])data;
       
        TableColumnManager tcManager = TableColumnManager.getInstance();
       
        Class   dataSource   = (Class)params[0];
        String  columnName  = (String)params[1];
       
        tcManager.registerColumn(dataSource, columnName, (TableColumnCreationListener)params[2]);
       
        String[] tables = tcManager.getTableIDs();
       
        for ( String tid: tables ){
         
            // we don't know which tables are affected at this point to refresh all.
            // if this proves to be a performance issue then we would have to use the
            // datasource to derive affected tables somehow
         
          TableStructureEventDispatcher tsed = TableStructureEventDispatcher.getInstance( tid );
             
          tsed.tableStructureChanged(true, dataSource);
        }
       
        break;
      }
      case UIManagerEvent.ET_UNREGISTER_COLUMN:{
       
        Object[] params = (Object[])data;
       
        TableColumnManager tcManager = TableColumnManager.getInstance();
       
        Class   dataSource   = (Class)params[0];
        String  columnName  = (String)params[1];

        tcManager.unregisterColumn(dataSource, columnName, (TableColumnCreationListener)params[2]);
       
        String[] tables = tcManager.getTableIDs();
       
        for ( String tid: tables ){
         
          TableColumnCore col = tcManager.getTableColumnCore( tid, columnName );
         
          if ( col != null ){
         
            col.remove();
          }
View Full Code Here

    expandFilters.setSpacing(1);
   
    final Composite cFilterArea = new Composite(expandFilters, SWT.NONE);
    cFilterArea.setLayout(new FormLayout());

    final TableColumnManager tcm = TableColumnManager.getInstance();

    Group cResultArea = new Group(shell, SWT.NONE);
    Messages.setLanguageText(cResultArea, "ColumnSetup.chosencolumns");
    cResultArea.setLayout(new FormLayout());
   
    Composite cResultButtonArea = new Composite(cResultArea, SWT.NONE);
    cResultButtonArea.setLayout(new FormLayout());

    tvAvail = createTVAvail();

    cTableAvail = new Composite(cPickArea, SWT.NO_FOCUS);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = gridLayout.marginHeight = 0;
    cTableAvail.setLayout(gridLayout);

    tvAvail.initialize(cTableAvail);

    TableColumnCore[] datasources = tcm.getAllTableColumnCoreAsArray(
        forDataSourceType, forTableID);

    listColumnsNoCat = new ArrayList<TableColumnCore>(
        Arrays.asList(datasources));
    listCats = new ArrayList<String>();
    for (int i = 0; i < datasources.length; i++) {
      TableColumnCore column = datasources[i];
      TableColumnInfo info = tcm.getColumnInfo(forDataSourceType, forTableID,
          column.getName());
      if (info != null) {
        String[] categories = info.getCategories();
        if (categories != null && categories.length > 0) {
          for (int j = 0; j < categories.length; j++) {
            String cat = categories[j];
            if (!listCats.contains(cat)) {
              listCats.add(cat);
            }
          }
          listColumnsNoCat.remove(column);
        }
      }
    }

    Listener radListener = new Listener() {
      public void handleEvent(Event event) {
        fillAvail();
      }
    };


    Composite cProficiency = new Composite(cFilterArea, SWT.NONE);
    cProficiency.setBackgroundMode(SWT.INHERIT_FORCE);
    cProficiency.setLayout(new FormLayout());

    Label lblProficiency = new Label(cProficiency, SWT.NONE);
    Messages.setLanguageText(lblProficiency, "ColumnSetup.proficiency");

    radProficiency[0] = new Button(cProficiency, SWT.RADIO);
    Messages.setLanguageText(radProficiency[0], "ConfigView.section.mode.beginner");
    fd = new FormData();
    fd.left = new FormAttachment(lblProficiency, 5);
    radProficiency[0].setLayoutData(fd);
    radProficiency[0].addListener(SWT.Selection, radListener);

    radProficiency[1] = new Button(cProficiency, SWT.RADIO);
    Messages.setLanguageText(radProficiency[1], "ConfigView.section.mode.intermediate");
    fd = new FormData();
    fd.left = new FormAttachment(radProficiency[0], 5);
    radProficiency[1].setLayoutData(fd);
    radProficiency[1].addListener(SWT.Selection, radListener);

    radProficiency[2] = new Button(cProficiency, SWT.RADIO);
    Messages.setLanguageText(radProficiency[2], "ConfigView.section.mode.advanced");
    fd = new FormData();
    fd.left = new FormAttachment(radProficiency[1], 5);
    radProficiency[2].setLayoutData(fd);
    radProficiency[2].addListener(SWT.Selection, radListener);

    int userMode = COConfigurationManager.getIntParameter("User Mode");
    if (userMode < 0) {
      userMode = 0;
    } else if (userMode >= radProficiency.length) {
      userMode = radProficiency.length - 1;
    }
    radProficiency[userMode].setSelection(true);

    // >>>>>>>> Buttons

    Listener buttonListener = new Listener() {
      public void handleEvent(Event event) {
        Control[] children = cCategories.getChildren();
        for (int i = 0; i < children.length; i++) {
          Control child = children[i];
          if (child != event.widget && (child instanceof Button)) {
            Button btn = (Button) child;
            btn.setSelection(false);
          }
        }
       
        fillAvail();
      }
    };
   
    Label lblCat = new Label(cFilterArea, SWT.NONE);
    Messages.setLanguageText(lblCat, "ColumnSetup.categories");
   
    if (CAT_BUTTONS) {
      cCategories = new Composite(cFilterArea, SWT.NONE);
      cCategories.setLayout(new RowLayout());

      Button button = new Button(cCategories, SWT.TOGGLE);
      Messages.setLanguageText(button, "Categories.all");
      button.addListener(SWT.Selection, buttonListener);
      button.setSelection(true);
 
      for (String cat : listCats) {
        button = new Button(cCategories, SWT.TOGGLE);
        button.setData("cat", cat);
        if (MessageText.keyExists("ColumnCategory." + cat)) {
          button.setText(MessageText.getString("ColumnCategory." + cat));
        } else {
          button.setText(cat);
        }
        button.addListener(SWT.Selection, buttonListener);
      }
 
      if (listColumnsNoCat.size() > 0) {
        button = new Button(cCategories, SWT.TOGGLE);
        if (MessageText.keyExists("ColumnCategory.uncat")) {
          button.setText(MessageText.getString("ColumnCategory.uncat"));
        } else {
          button.setText("?");
        }
        button.setText("?");
        button.setData("cat", "uncat");
        button.addListener(SWT.Selection, buttonListener);
      }
    } else {
      comboFilter = new Combo(cFilterArea, SWT.DROP_DOWN | SWT.READ_ONLY);
      comboFilter.addListener(SWT.Selection, radListener);

      listCats.add(0, "all");
      for (String cat : listCats) {
        comboFilter.add(cat);
      }
      comboFilter.select(0);
    }
   
    final ExpandItem expandItemFilters = new ExpandItem(expandFilters, SWT.NONE);
    expandItemFilters.setText(MessageText.getString("ColumnSetup.filters"));
    expandItemFilters.setControl(cFilterArea);
    expandFilters.addListener(SWT.Resize, new Listener() {
      public void handleEvent(Event event) {
        expandItemFilters.setHeight(cFilterArea.computeSize(
            expandFilters.getSize().x, SWT.DEFAULT).y + 3);
      }
    });

    expandFilters.addListener(SWT.Expand, new Listener() {
      public void handleEvent(Event event) {
        Utils.execSWTThreadLater(Constants.isLinux ? 250 : 0, new AERunnable() {
          public void runSupport() {
            shell.layout(true, true);
          }
        });
      }
    });
    expandFilters.addListener(SWT.Collapse, new Listener() {
      public void handleEvent(Event event) {
        Utils.execSWTThreadLater(Constants.isLinux ? 250 : 0, new AERunnable() {
          public void runSupport() {
            shell.layout(true, true);
          }
        });
      }
    });
   

    // <<<<<<< Buttons
   
    // >>>>>>> Chosen

    ImageLoader imageLoader = ImageLoader.getInstance();

    Button btnUp = new Button(cResultButtonArea, SWT.PUSH);
    imageLoader.setButtonImage(btnUp, "up");
    btnUp.addSelectionListener(new SelectionListener() {
      public void widgetSelected(SelectionEvent e) {
        moveChosenUp();
      }

      public void widgetDefaultSelected(SelectionEvent e) {
      }
    });

    Button btnDown = new Button(cResultButtonArea, SWT.PUSH);
    imageLoader.setButtonImage(btnDown, "down");
    btnDown.addSelectionListener(new SelectionListener() {
      public void widgetSelected(SelectionEvent e) {
        moveChosenDown();
      }

      public void widgetDefaultSelected(SelectionEvent e) {
      }
    });

    Button btnDel = new Button(cResultButtonArea, SWT.PUSH);
    imageLoader.setButtonImage(btnDel, "delete");
    btnDel.addSelectionListener(new SelectionListener() {
      public void widgetSelected(SelectionEvent e) {
        removeSelectedChosen();
      }

      public void widgetDefaultSelected(SelectionEvent e) {
      }
    });

    tvChosen = createTVChosen();

    cTableChosen = new Composite(cResultArea, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.marginWidth = gridLayout.marginHeight = 0;
    cTableChosen.setLayout(gridLayout);

    tvChosen.initialize(cTableChosen);

    columnsChosen = tcm.getAllTableColumnCoreAsArray(forDataSourceType,
        forTableID);
    Arrays.sort(columnsChosen,
        TableColumnManager.getTableColumnOrderComparator());
    columnsOriginalOrder = new TableColumnCore[columnsChosen.length];
    System.arraycopy(columnsChosen, 0, columnsOriginalOrder, 0,
        columnsChosen.length);
    int pos = 0;
    for (int i = 0; i < columnsChosen.length; i++) {
      boolean visible = columnsChosen[i].isVisible();
      mapNewVisibility.put(columnsChosen[i], new Boolean(visible));
      if (visible) {
        columnsChosen[i].setPositionNoShift(pos++);
        tvChosen.addDataSource(columnsChosen[i]);
      }
    }
    tvChosen.processDataSourceQueue();

   
    Button btnReset = null;
    String[] defaultColumnNames = tcm.getDefaultColumnNames(forTableID);
    if (defaultColumnNames != null) {
      btnReset = new Button(cResultButtonArea, SWT.PUSH);
      Messages.setLanguageText(btnReset, "Button.reset");
      btnReset.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
          String[] defaultColumnNames = tcm.getDefaultColumnNames(forTableID);
          if (defaultColumnNames != null) {
            List<TableColumnCore> defaultColumns = new ArrayList<TableColumnCore>();
            for (String name : defaultColumnNames) {
              TableColumnCore column = tcm.getTableColumnCore(forTableID, name);
              if (column != null) {
                defaultColumns.add(column);
              }
            }
            if (defaultColumns.size() > 0) {
View Full Code Here

    }
    cPickArea.setText(s);

    tvAvail.removeAllTableRows();

    final TableColumnManager tcm = TableColumnManager.getInstance();
    TableColumnCore[] datasources = tcm.getAllTableColumnCoreAsArray(
        forDataSourceType, forTableID);
   
    if (selectedCat == "uncat") {
      datasources = (TableColumnCore[]) listColumnsNoCat.toArray( new TableColumnCore[listColumnsNoCat.size()]);
    }
    for (int i = 0; i < datasources.length; i++) {
      TableColumnCore column = datasources[i];
      TableColumnInfo info = tcm.getColumnInfo(forDataSourceType,
          forTableID, column.getName());
      String[] cats = info == null ? null : info.getCategories();
      if (cats == null) {
        if (selectedCat == null || selectedCat.equals("uncat")) {
          tvAvail.addDataSource(column);
View Full Code Here

   * @return
   *
   * @since 4.0.0.5
   */
  private TableViewColumnSetup createTVChosen() {
    final TableColumnManager tcm = TableColumnManager.getInstance();
    TableColumnCore[] columnTVChosen = tcm.getAllTableColumnCoreAsArray(
        TableColumn.class, TABLEID_CHOSEN);
    for (int i = 0; i < columnTVChosen.length; i++) {
      TableColumnCore column = columnTVChosen[i];
      if (column.getName().equals(ColumnTC_ChosenColumn.COLUMN_ID)) {
        column.setVisible(true);
View Full Code Here

   * @return
   *
   * @since 4.0.0.5
   */
  private TableViewColumnSetup createTVAvail() {
    final TableColumnManager tcm = TableColumnManager.getInstance();
    Map mapColumns = tcm.getTableColumnsAsMap(TableColumn.class, TABLEID_AVAIL);
    TableColumnCore[] columns;
    int[] widths = { 405, 120 };
    if (sampleRow == null) {
      columns = new TableColumnCore[] {
        (TableColumnCore) mapColumns.get(ColumnTC_NameInfo.COLUMN_ID),
View Full Code Here

        new ColumnSubscriptionAutoDownload(TABLE_ID),
        new ColumnSubscriptionCategory(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 Full Code Here

          public void tableColumnCreated(TableColumn column) {
            new ColumnCS_Pct(column);
          }
        });
   
    TableColumnManager tcManager = TableColumnManager.getInstance();
    tcManager.setDefaultColumnNames(TABLEID, new String[] {
      ColumnCS_Name.COLUMN_ID,
      ColumnCS_Pct.COLUMN_ID,
      ColumnCS_Count.COLUMN_ID,
      /*
      ColumnCS_Received.COLUMN_ID,
 
View Full Code Here

    TableColumnCore[] columns = useBigTable
        || torrentFilterMode != SBC_LibraryView.TORRENTS_ALL ? getColumns()
        : null;

    if (null != columns) {
      TableColumnManager tcManager = TableColumnManager.getInstance();
      tcManager.addColumns(columns);
    }

    if (useBigTable) {
      if (torrentFilterMode == SBC_LibraryView.TORRENTS_COMPLETE
          || torrentFilterMode == SBC_LibraryView.TORRENTS_INCOMPLETE
View Full Code Here

          public void tableColumnCreated(TableColumn column) {
            new ColumnOD_Remaining(column);
          }
        });

    TableColumnManager tcm = TableColumnManager.getInstance();
    TableColumnCore[] allTCs = tcm.getAllTableColumnCoreAsArray(
        DeviceOfflineDownload.class, TABLE_RCM);
    // for now, all columns are default
    ArrayList<String> names = new ArrayList<String>();
    for (int i = 0; i < allTCs.length; i++) {
      TableColumn tc = allTCs[i];
      if (tc.isVisible()) {
        names.add(tc.getName());
      }
    }
    tcm.setDefaultColumnNames(TABLE_RCM, names.toArray(new String[0]));
}
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.ui.common.table.impl.TableColumnManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.