⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tablecolumnsetupwindow.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
					}

					
					{
						this$1 = 8.this;
						super();
					}
				});
			}

			
			{
				this$0 = TableColumnSetupWindow.this;
				super();
			}
		});
		ImageLoader imageLoader = ImageLoader.getInstance();
		Button btnUp = new Button(cResultArea, 8);
		imageLoader.setButtonImage(btnUp, "up");
		btnUp.addSelectionListener(new SelectionListener() {

			final TableColumnSetupWindow this$0;

			public void widgetSelected(SelectionEvent e)
			{
				moveChosenUp();
			}

			public void widgetDefaultSelected(SelectionEvent selectionevent)
			{
			}

			
			{
				this$0 = TableColumnSetupWindow.this;
				super();
			}
		});
		Button btnDown = new Button(cResultArea, 8);
		imageLoader.setButtonImage(btnDown, "down");
		btnDown.addSelectionListener(new SelectionListener() {

			final TableColumnSetupWindow this$0;

			public void widgetSelected(SelectionEvent e)
			{
				moveChosenDown();
			}

			public void widgetDefaultSelected(SelectionEvent selectionevent)
			{
			}

			
			{
				this$0 = TableColumnSetupWindow.this;
				super();
			}
		});
		Button btnDel = new Button(cResultArea, 8);
		imageLoader.setButtonImage(btnDel, "delete");
		btnDel.addSelectionListener(new SelectionListener() {

			final TableColumnSetupWindow this$0;

			public void widgetSelected(SelectionEvent e)
			{
				removeSelectedChosen();
			}

			public void widgetDefaultSelected(SelectionEvent selectionevent)
			{
			}

			
			{
				this$0 = TableColumnSetupWindow.this;
				super();
			}
		});
		tvChosen = createTVChosen();
		cTableChosen = new Composite(cResultArea, 0);
		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 btnCancel = new Button(shell, 8);
		Messages.setLanguageText(btnCancel, "Button.cancel");
		btnCancel.addSelectionListener(new SelectionAdapter() {

			final TableColumnSetupWindow this$0;

			public void widgetSelected(SelectionEvent e)
			{
				shell.dispose();
			}

			
			{
				this$0 = TableColumnSetupWindow.this;
				super();
			}
		});
		Button btnApply = new Button(shell, 8);
		Messages.setLanguageText(btnApply, "Button.apply");
		btnApply.addSelectionListener(new SelectionAdapter() {

			final TableColumnSetupWindow this$0;

			public void widgetSelected(SelectionEvent e)
			{
				apply();
			}

			
			{
				this$0 = TableColumnSetupWindow.this;
				super();
			}
		});
		fd = new FormData();
		fd.left = new FormAttachment(0, 5);
		fd.right = new FormAttachment(100, -5);
		fd = new FormData();
		fd.right = new FormAttachment(btnDown, -5);
		fd.bottom = new FormAttachment(100, -3);
		btnUp.setLayoutData(fd);
		fd = new FormData();
		fd.right = new FormAttachment(btnDel, -5);
		fd.top = new FormAttachment(btnUp, 0, 128);
		fd.bottom = new FormAttachment(btnUp, 0, 1024);
		btnDown.setLayoutData(fd);
		fd = new FormData();
		fd.right = new FormAttachment(100, -5);
		fd.top = new FormAttachment(btnUp, 0, 128);
		fd.bottom = new FormAttachment(btnUp, 0, 1024);
		btnDel.setLayoutData(fd);
		fd = new FormData();
		fd.top = new FormAttachment(0, 3);
		fd.left = new FormAttachment(0, 0);
		fd.right = new FormAttachment(100, 0);
		fd.bottom = new FormAttachment(btnUp, -3);
		cTableChosen.setLayoutData(fd);
		fd = new FormData();
		fd.right = new FormAttachment(100, -8);
		fd.bottom = new FormAttachment(100, -3);
		btnApply.setLayoutData(fd);
		fd = new FormData();
		fd.right = new FormAttachment(btnApply, -3);
		fd.bottom = new FormAttachment(btnApply, 0, 1024);
		btnCancel.setLayoutData(fd);
		fd = new FormData();
		fd.right = new FormAttachment(btnCancel, -3);
		fd.bottom = new FormAttachment(btnApply, 0, 1024);
		btnOk.setLayoutData(fd);
		fd = new FormData();
		fd.top = new FormAttachment(topInfo, 5);
		fd.left = new FormAttachment(0, 3);
		fd.right = new FormAttachment(cResultArea, -3);
		fd.bottom = new FormAttachment(100, -3);
		cPickArea.setLayoutData(fd);
		fd = new FormData();
		fd.bottom = new FormAttachment(100, 0);
		fd.left = new FormAttachment(0, 0);
		fd.right = new FormAttachment(100, 0);
		expandFilters.setLayoutData(fd);
		fd = new FormData();
		fd.bottom = new FormAttachment(cCategories, 0, 0x1000000);
		fd.left = new FormAttachment(0, 5);
		lblCat.setLayoutData(fd);
		fd = new FormData();
		fd.bottom = new FormAttachment(radProficiency[0], 0, 0x1000000);
		fd.left = new FormAttachment(0, 0);
		lblProficiency.setLayoutData(fd);
		fd = new FormData();
		fd.top = new FormAttachment(cProficiency, 5);
		fd.left = new FormAttachment(lblCat, 5);
		fd.right = new FormAttachment(100, 0);
		cCategories.setLayoutData(fd);
		fd = new FormData();
		fd.top = new FormAttachment(0, 5);
		fd.left = new FormAttachment(0, 5);
		cProficiency.setLayoutData(fd);
		fd = new FormData();
		fd.top = new FormAttachment(0, 3);
		fd.left = new FormAttachment(0, 0);
		fd.right = new FormAttachment(100, 0);
		fd.bottom = new FormAttachment(expandFilters, -3);
		cTableAvail.setLayoutData(fd);
		shell.setTabList(new Control[] {
			cPickArea, cResultArea, btnOk, btnCancel, btnApply
		});
		cPickArea.setTabList(new Control[] {
			cTableAvail
		});
		fillAvail();
		UIUpdaterSWT.getInstance().addUpdater(this);
	}

	protected void fillAvail()
	{
		String selectedCat = null;
		Control children[] = cCategories.getChildren();
		byte i;
		for (i = 0; i < children.length; i++)
		{
			Control child = children[i];
			if (!(child instanceof Button))
				continue;
			Button btn = (Button)child;
			if (!btn.getSelection())
				continue;
			selectedCat = (String)btn.getData("cat");
			break;
		}

		if (selectedCat != null && selectedCat.equals("all"))
			selectedCat = null;
		byte selectedProf = 0;
		i = 0;
		do
		{
			if (i >= radProficiency.length)
				break;
			Button btn = radProficiency[i];
			if (btn.getSelection())
			{
				selectedProf = i;
				break;
			}
			i++;
		} while (true);
		String s;
		if (selectedCat != null)
			s = MessageText.getString("ColumnSetup.availcolumns.filteredby", new String[] {
				radProficiency[selectedProf].getText(), selectedCat
			});
		else
			s = MessageText.getString("ColumnSetup.availcolumns", new String[] {
				radProficiency[selectedProf].getText()
			});
		cPickArea.setText(s);
		tvAvail.removeAllTableRows();
		TableColumnManager tcm = TableColumnManager.getInstance();
		TableColumnCore datasources[] = tcm.getAllTableColumnCoreAsArray(forDataSourceType, forTableID);
		if (selectedCat == "uncat")
			datasources = (TableColumnCore[])(TableColumnCore[])listColumnsNoCat.toArray(new TableColumnCore[listColumnsNoCat.size()]);
label0:
		for (int i = 0; i < datasources.length; i++)
		{
			TableColumnCore column = datasources[i];
			TableColumnInfo info = tcm.getColumnInfo(forDataSourceType, forTableID, column.getName());
			String cats[] = info != null ? info.getCategories() : null;
			if (cats == null)
			{
				if (selectedCat == null || selectedCat.equals("uncat"))
					tvAvail.addDataSource(column);
				continue;
			}
			int j = 0;
			do
			{
				if (j >= cats.length)
					continue label0;
				String cat = cats[j];
				if ((selectedCat == null || selectedCat.equalsIgnoreCase(cat)) && info.getProficiency() <= selectedProf)
				{
					tvAvail.addDataSource(column);
					continue label0;
				}
				j++;
			} while (true);
		}

		tvAvail.processDataSourceQueue();
	}

	protected void removeSelectedChosen()
	{
		Object datasources[] = tvChosen.getSelectedDataSources().toArray();
		for (int i = 0; i < datasources.length; i++)
		{
			TableColumnCore column = (TableColumnCore)datasources[i];
			mapNewVisibility.put(column, Boolean.FALSE);
		}

		tvChosen.removeDataSources(datasources);
		tvChosen.processDataSourceQueue();
		for (int i = 0; i < datasources.length; i++)
		{
			TableRowSWT row = (TableRowSWT)tvAvail.getRow(datasources[i]);
			if (row != null)
				row.redraw();
		}

	}

	protected void moveChosenDown()
	{
		TableRowCore selectedRows[] = tvChosen.getSelectedRows();
		TableRowCore rows[] = tvChosen.getRows();
		for (int i = selectedRows.length - 1; i >= 0; i--)
		{
			TableRowCore row = selectedRows[i];
			TableColumnCore column = (TableColumnCore)row.getDataSource();
			if (column == null)
				continue;
			int oldColumnPos = column.getPosition();
			int oldRowPos = row.getIndex();
			if (oldRowPos < rows.length - 1)
			{
				TableRowCore displacedRow = rows[oldRowPos + 1];
				((TableColumnCore)displacedRow.getDataSource()).setPositionNoShift(oldColumnPos);
				rows[oldRowPos + 1] = rows[oldRowPos];
				rows[oldRowPos] = displacedRow;
				column.setPositionNoShift(oldColumnPos + 1);
			}
		}

		tvChosen.tableInvalidate();
		tvChosen.refreshTable(true);
	}

	protected void moveChosenUp()
	{
		TableRowCore selectedRows[] = tvChosen.getSelectedRows();
		TableRowCore rows[] = tvChosen.getRows();
		for (int i = 0; i < selectedRows.length; i++)
		{
			TableRowCore row = selectedRows[i];
			TableColumnCore column = (TableColumnCore)row.getDataSource();
			if (column == null)
				continue;
			int oldColumnPos = column.getPosition();
			int oldRowPos = row.getIndex();
			if (oldRowPos > 0)
			{
				TableRowCore displacedRow = rows[oldRowPos - 1];
				((TableColumnCore)displacedRow.getDataSource()).setPositionNoShift(oldColumnPos);
				rows[oldRowPos - 1] = rows[oldRowPos];
				rows[oldRowPos] = displacedRow;
				column.setPositionNoShift(oldColumnPos - 1);
			}
		}

		tvChosen.tableInvalidate();
		tvChosen.refreshTable(true);
	}

	protected void apply()
	{
		for (int i = 0; i < columnsChosen.length; i++)
		{
			TableColumnCore column = columnsChosen[i];
			if (column != null)
				column.setVisible(((Boolean)mapNewVisibility.get(column)).booleanValue());
		}

		TableColumnManager.getInstance().saveTableColumns(forDataSourceType, forTableID);
		listener.tableStructureChanged(true);
	}

	private TableViewColumnSetup createTVChosen()
	{
		TableColumnManager tcm = TableColumnManager.getInstance();
		TableColumnCore columnTVChosen[] = tcm.getAllTableColumnCoreAsArray(org/gudy/azureus2/plugins/ui/tables/TableColumn, "ColumnSetupChosen");
		for (int i = 0; i < columnTVChosen.length; i++)
		{
			TableColumnCore column = columnTVChosen[i];
			if (column.getName().equals("TableColumnChosenColumn"))
			{
				column.setVisible(true);
				column.setWidth(175);
				column.setSortAscending(true);
			} else
			{
				column.setVisible(false);
			}
		}

		final TableViewColumnSetup tvChosen = new TableViewColumnSetup(this, "ColumnSetupChosen", columnTVChosen, "TableColumnChosenColumn", true);
		tvChosen.setMenuEnabled(false);
		tvChosen.setSampleRow(sampleRow);
		tvChosen.setHeaderVisible(false);
		tvChosen.setDataSourceType(org/gudy/azureus2/plugins/ui/tables/TableColumn);
		tvChosen.addLifeCycleListener(new TableLifeCycleListener() {

			private DragSource dragSource;
			private DropTarget dropTarget;
			final TableViewColumnSetup val$tvChosen;
			final TableColumnSetupWindow this$0;

			public void tableViewInitialized()
			{
				dragSource = tvChosen.createDragSource(7);
				dragSource.setTransfer(new Transfer[] {
					TextTransfer.getInstance()
				});
				dragSource.addDragListener(dragSourceListener);
				dropTarget = tvChosen.createDropTarget(31);
				dropTarget.setTransfer(new Transfer[] {
					TextTransfer.getInstance()
				});
				dropTarget.addDropListener(new DropTargetListener() {

					final 14 this$1;

					public void dropAccept(DropTargetEvent droptargetevent)
					{
					}

					public void drop(DropTargetEvent event)
					{
						String id = (String)event.data;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -