diff --git a/plugins/ru.runa.gpd.form.ftl/plugin.properties b/plugins/ru.runa.gpd.form.ftl/plugin.properties
index 1a6f0c908..5cd9cac5f 100644
--- a/plugins/ru.runa.gpd.form.ftl/plugin.properties
+++ b/plugins/ru.runa.gpd.form.ftl/plugin.properties
@@ -104,6 +104,7 @@ Method.DisplayMultipleSelectInList = Display multiple selection
Method.SelectFromValueList = Select value from value list
Method.MultipleSelectFromListUserVariables = Multiple select from user variables list (deprecated)
Method.MultipleSelectFromUserTypeList = Multiple select from user variables list
+Method.SingleSelectFromUserTypeList = Single select from user variables list
Method.EditUserTypeList = Edit list of user variables
Method.DisplayListUserVariables = Display list of user variables (deprecated)
Method.DisplayUserTypeList = Display list of user variables
diff --git a/plugins/ru.runa.gpd.form.ftl/plugin.xml b/plugins/ru.runa.gpd.form.ftl/plugin.xml
index f667d2e2d..246a79816 100644
--- a/plugins/ru.runa.gpd.form.ftl/plugin.xml
+++ b/plugins/ru.runa.gpd.form.ftl/plugin.xml
@@ -1131,11 +1131,50 @@
variableAccess="NONE">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ order="-80">
+ order="-79">
+ order="-78">
importer;
private final WfeServerConnectorSynchronizationCallback callback;
private Combo combo;
+ private Hyperlink addConnectionLink;
private Hyperlink settingsLink;
private Hyperlink synchronizeLink;
@@ -35,8 +38,10 @@ public WfeServerConnectorComposite(Composite parent, WfeServerConnectorDataImpor
super(parent, SWT.NONE);
this.importer = importer;
this.callback = callback;
- setLayout(new GridLayout(3, true));
+ setLayout(new GridLayout(4, false));
+
createCombo();
+ createAddConnectionLink();
createConnectionSettingsLink();
createSynchronizeLink();
}
@@ -45,6 +50,7 @@ public WfeServerConnectorComposite(Composite parent, WfeServerConnectorDataImpor
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
combo.setEnabled(enabled);
+ addConnectionLink.setEnabled(enabled);
settingsLink.setEnabled(enabled);
synchronizeLink.setEnabled(enabled && WfeServerConnector.getInstance().isConfigured());
}
@@ -79,6 +85,33 @@ protected void onSelection(SelectionEvent e) throws Exception {
});
}
+ private void createAddConnectionLink() {
+ addConnectionLink = SwtUtils.createLink(this, Localization.getString("button.add.connection.server"), new LoggingHyperlinkAdapter() {
+
+ @Override
+ protected void onLinkActivated(HyperlinkEvent e) {
+ getShell().dispose();
+ openAddConnectionDialog();
+ }
+
+ });
+ }
+
+ private void openAddConnectionDialog() {
+ WfeServerConnectorsPreferenceNode wfeServerConnectorsNode = WfeServerConnectorsPreferenceNode.getInstance();
+ IPreferenceNode[] children = wfeServerConnectorsNode.getSubNodes();
+ WfeServerConnectorPreferenceNode lastNode = (WfeServerConnectorPreferenceNode) children[children.length - 1];
+ WfeServerConnectorPreferenceNode node = new WfeServerConnectorPreferenceNode(lastNode.getIndex() + 1);
+ wfeServerConnectorsNode.add(node);
+ wfeServerConnectorsNode.saveIndices();
+ WfeServerConnectorSettings connectorSettings = WfeServerConnectorSettings.createDefault(node.getIndex());
+ connectorSettings.saveToStore();
+ children = wfeServerConnectorsNode.getSubNodes();
+ lastNode = (WfeServerConnectorPreferenceNode) children[children.length - 1];
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, "gpd.pref.connector.wfe." + lastNode.getIndex(), null, null);
+ dialog.open();
+ }
+
private void createConnectionSettingsLink() {
settingsLink = SwtUtils.createLink(this, Localization.getString("button.ConnectionSettings"), new LoggingHyperlinkAdapter() {
diff --git a/plugins/ru.runa.gpd/src/ru/runa/gpd/ui/wizard/ImportParWizardPage.java b/plugins/ru.runa.gpd/src/ru/runa/gpd/ui/wizard/ImportParWizardPage.java
index d619143d8..01cffc276 100644
--- a/plugins/ru.runa.gpd/src/ru/runa/gpd/ui/wizard/ImportParWizardPage.java
+++ b/plugins/ru.runa.gpd/src/ru/runa/gpd/ui/wizard/ImportParWizardPage.java
@@ -1,5 +1,6 @@
package ru.runa.gpd.ui.wizard;
+import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import java.io.ByteArrayInputStream;
@@ -9,6 +10,8 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -21,6 +24,7 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.ModifyEvent;
@@ -38,6 +42,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.internal.WorkbenchImages;
import ru.runa.gpd.Localization;
import ru.runa.gpd.PluginLogger;
import ru.runa.gpd.SharedImages;
@@ -60,6 +66,7 @@ public class ImportParWizardPage extends ImportWizardPage {
private WfeServerConnectorComposite serverConnectorComposite;
private TreeViewer serverDefinitionViewer;
private Text serverDefinitionFilter;
+ private Button clearFilterButton;
private String selectedDirFileName;
private String[] selectedFileNames;
@@ -158,6 +165,8 @@ private void onImportModeChanged() {
selectParsButton.setEnabled(fromFile);
serverConnectorComposite.setEnabled(!fromFile);
serverDefinitionViewer.getControl().setEnabled(!fromFile);
+ serverDefinitionFilter.setEnabled(!fromFile);
+ clearFilterButton.setEnabled(!fromFile);
if (fromFile) {
updateServerDefinitionViewer(null);
} else {
@@ -166,6 +175,7 @@ private void onImportModeChanged() {
}
private void updateServerDefinitionViewer(List definitions) {
+ serverDefinitionFilter.setText("");
if (definitions != null) {
DefinitionTreeNode treeDefinitions = createTree(definitions);
serverDefinitionViewer.setInput(treeDefinitions);
@@ -176,20 +186,38 @@ private void updateServerDefinitionViewer(List definitions) {
}
private void createServerDefinitionsGroup(Composite parent) {
- serverDefinitionFilter = new Text(parent, SWT.SINGLE | SWT.BORDER);
- GridData gridDataText = new GridData(SWT.FILL,SWT.BEGINNING, true, false);
- serverDefinitionFilter.setLayoutData(gridDataText);
+ Composite filterArea = new Composite(parent, SWT.NONE);
+ filterArea.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
+ GridLayout filterLayout = new GridLayout();
+ filterLayout.numColumns = 2;
+ filterLayout.makeColumnsEqualWidth = false;
+ filterLayout.marginWidth = 0;
+ filterLayout.marginHeight = 0;
+ filterArea.setLayout(filterLayout);
+ serverDefinitionFilter = new Text(filterArea, SWT.SINGLE | SWT.BORDER);
+ serverDefinitionFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
serverDefinitionFilter.setMessage(Localization.getString("text.message.filter"));
- serverDefinitionFilter.addModifyListener(new ModifyListener( ) {
+ serverDefinitionFilter.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
serverDefinitionViewer.refresh();
- }});
-
+ }
+ });
+ clearFilterButton = new Button(filterArea, SWT.PUSH);
+ clearFilterButton.setToolTipText(Localization.getString("button.clear"));
+ clearFilterButton.setImage(WorkbenchImages.getImage(ISharedImages.IMG_ETOOL_CLEAR));
+ clearFilterButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+ clearFilterButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ serverDefinitionFilter.setText("");
+ }
+ });
serverDefinitionViewer = new TreeViewer(parent);
GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.heightHint = 100;
+ gridData.heightHint = 300;
serverDefinitionViewer.getControl().setLayoutData(gridData);
serverDefinitionViewer.setContentProvider(new ViewContentProvider());
serverDefinitionViewer.setLabelProvider(new ViewLabelProvider());
@@ -197,24 +225,18 @@ public void modifyText(ModifyEvent e) {
serverDefinitionViewer.addFilter(new ViewerFilter() {
@Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
String searchText = serverDefinitionFilter.getText();
if (searchText == null || searchText.trim().length() == 0) {
return true;
}
-
- if ((element instanceof DefinitionTreeNode) ) {
- String name = ((DefinitionTreeNode) element).getLabel();
-
- if (((DefinitionTreeNode) element).definition == null) {
- // This is the node. Show nodes with at least one matching child definition
- return matchAtLeastOneSub(((DefinitionTreeNode) element).getChildren(), searchText);
- }
-
- // filter leafs only
- if (name.toLowerCase().contains(searchText.trim().toLowerCase())) {
- return true;
- }
+ DefinitionTreeNode node = (DefinitionTreeNode) element;
+ if (node.definition == null && node.isGroupNode()) {
+ // This is the node. Show nodes with at least one matching child definition
+ return matchAtLeastOneSub(node.children, searchText);
+ }
+ if (matchNode(node, searchText)) {
+ return true;
}
return false;
}});
@@ -225,19 +247,22 @@ private boolean matchAtLeastOneSub(List source, String searc
return false;
}
for (DefinitionTreeNode node: source) {
- String name = node.getLabel();
- if (name.toLowerCase().contains(searchText.trim().toLowerCase())) {
+ if (matchNode(node, searchText)) {
return true;
}
- if (node.getChildren() != null && node.getChildren().size() > 0) {
- boolean bSub = matchAtLeastOneSub(node.getChildren(), searchText);
+ if (node.children.size() > 0) {
+ boolean bSub = matchAtLeastOneSub(node.children, searchText);
if (bSub) {
return true;
}
}
}
return false;
- }
+ }
+
+ private boolean matchNode(DefinitionTreeNode node, String searchText) {
+ return node.definition != null && node.definition.getName().toLowerCase().contains(searchText.trim().toLowerCase());
+ }
public boolean performFinish() {
List importInfos = Lists.newArrayList();
@@ -290,6 +315,28 @@ public boolean performFinish() {
private DefinitionTreeNode createTree(List definitions) {
DefinitionTreeNode rootTreeNode = new DefinitionTreeNode("", "", null, false, false);
+ Collections.sort(definitions, new Comparator() {
+
+ @Override
+ public int compare(WfDefinition o1, WfDefinition o2) {
+ String[] categories1 = o1.getCategories();
+ String[] categories2 = o2.getCategories();
+ if (categoryIsEmpty(categories1)) {
+ if (categoryIsEmpty(categories2)) {
+ return 0;
+ }
+ return 1;
+ }
+ if (categoryIsEmpty(categories2)) {
+ return -1;
+ }
+ return categories1[0].compareTo(categories2[0]);
+ }
+
+ private boolean categoryIsEmpty(String[] categories) {
+ return categories == null || categories.length == 0 || Strings.isNullOrEmpty(categories[0]) || categories[0].trim().length() == 0;
+ }
+ });
for (WfDefinition definition : definitions) {
rootTreeNode.addElementToTree(rootTreeNode.path, definition.getCategories(), definition);
}
@@ -426,7 +473,7 @@ private List getChildren() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- monitor.beginTask(Localization.getString("task.LoadData"), 1);
+ monitor.beginTask(NLS.bind(Localization.getString("task.LoadHistoryData"), definition.getName()), 1);
List list = WfeServerConnector.getInstance().getProcessDefinitionHistory(definition);
if (list.isEmpty()) {
String label = Localization.getString("ImportParWizardPage.page.oldDefinitionVersions.empty");