提交 281e878e 编写于 作者: S Serge Rider

#1149 Maven repo disable/reorder. Prefs.

上级 7fffcecb
......@@ -198,6 +198,9 @@ public class MavenRegistry
// Try all available repositories (without resolve)
for (MavenRepository repository : repositories) {
if (!repository.isEnabled()) {
continue;
}
if (repository != currentRepository) {
if (!repository.getScopes().isEmpty()) {
// Check scope (group id)
......
......@@ -975,13 +975,13 @@ public class UIUtils {
shell.setText(title);
}
public static void showPreferencesFor(Shell shell, Object element, String defPageID)
public static void showPreferencesFor(Shell shell, Object element, String ... defPageID)
{
PreferenceDialog propDialog;
if (element == null) {
propDialog = PreferencesUtil.createPreferenceDialogOn(shell, defPageID, new String[] { defPageID }, null, PreferencesUtil.OPTION_NONE);
propDialog = PreferencesUtil.createPreferenceDialogOn(shell, defPageID[0], defPageID, null, PreferencesUtil.OPTION_NONE);
} else {
propDialog = PreferencesUtil.createPropertyDialogOn(shell, element, defPageID, null, null, PreferencesUtil.OPTION_NONE);
propDialog = PreferencesUtil.createPropertyDialogOn(shell, element, defPageID[0], defPageID, null, PreferencesUtil.OPTION_NONE);
}
if (propDialog != null) {
propDialog.open();
......
......@@ -28,6 +28,7 @@ import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.runtime.WebUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.preferences.PrefPageDrivers;
import org.jkiss.dbeaver.ui.preferences.PrefPageDriversMaven;
import org.jkiss.utils.CommonUtils;
abstract class DriverDownloadPage extends WizardPage {
......@@ -80,7 +81,8 @@ abstract class DriverDownloadPage extends WizardPage {
UIUtils.showPreferencesFor(
null,
null,
PrefPageDrivers.PAGE_ID);
PrefPageDrivers.PAGE_ID,
PrefPageDriversMaven.PAGE_ID);
}
});
link.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END));
......
......@@ -56,6 +56,8 @@ public class PrefPageDriversMaven extends AbstractPrefPage implements IWorkbench
private final Set<MavenRepository> disabledRepositories = new HashSet<>();
private Button disableButton;
private Button removeButton;
private Button moveUpButton;
private Button moveDownButton;
private Color enabledColor, disabledColor;
@Override
......@@ -124,6 +126,32 @@ public class PrefPageDriversMaven extends AbstractPrefPage implements IWorkbench
}
});
removeButton.setEnabled(false);
moveUpButton = UIUtils.createToolButton(buttonsPH, "Up", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final TableItem item = mavenRepoTable.getSelection()[0];
final int index = mavenRepoTable.indexOf(item);
if (index > 0) {
final TableItem prevItem = mavenRepoTable.getItem(index - 1);
switchItems(item, prevItem);
mavenRepoTable.setSelection(index - 1);
updateSelection();
}
}
});
moveDownButton = UIUtils.createToolButton(buttonsPH, "Down", new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final TableItem item = mavenRepoTable.getSelection()[0];
final int index = mavenRepoTable.indexOf(item);
if (index < mavenRepoTable.getItemCount() - 1) {
final TableItem nextItem = mavenRepoTable.getItem(index + 1);
switchItems(item, nextItem);
mavenRepoTable.setSelection(index + 1);
updateSelection();
}
}
});
mavenRepoTable.addSelectionListener(new SelectionAdapter() {
@Override
......@@ -180,6 +208,19 @@ public class PrefPageDriversMaven extends AbstractPrefPage implements IWorkbench
return composite;
}
private void switchItems(TableItem item1, TableItem item2) {
final String id1 = item1.getText(0);
final String url1 = item1.getText(1);
final Object repo1 = item1.getData();
item1.setText(0, item2.getText(0));
item1.setText(1, item2.getText(1));
item1.setData(item2.getData());
item2.setText(0, id1);
item2.setText(1, url1);
item2.setData(repo1);
}
private MavenRepository getSelectedRepository() {
TableItem[] selection = mavenRepoTable.getSelection();
if (selection.length == 1) {
......@@ -223,6 +264,8 @@ public class PrefPageDriversMaven extends AbstractPrefPage implements IWorkbench
urlText.setEnabled(false);
scopeText.setEnabled(false);
}
moveUpButton.setEnabled(mavenRepoTable.getSelectionIndex() > 0);
moveDownButton.setEnabled(mavenRepoTable.getSelectionIndex() < mavenRepoTable.getItemCount() - 1);
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册