summaryrefslogtreecommitdiffstats
path: root/src/com/ibm/ServerWizard2/view/MainDialog.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/ibm/ServerWizard2/view/MainDialog.java')
-rw-r--r--src/com/ibm/ServerWizard2/view/MainDialog.java168
1 files changed, 88 insertions, 80 deletions
diff --git a/src/com/ibm/ServerWizard2/view/MainDialog.java b/src/com/ibm/ServerWizard2/view/MainDialog.java
index bb472a6..3e7549f 100644
--- a/src/com/ibm/ServerWizard2/view/MainDialog.java
+++ b/src/com/ibm/ServerWizard2/view/MainDialog.java
@@ -1,8 +1,10 @@
package com.ibm.ServerWizard2.view;
-import java.util.Map;
+import java.io.File;
import java.util.Vector;
+import javax.swing.ProgressMonitor;
+
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -48,13 +50,29 @@ import org.eclipse.wb.swt.SWTResourceManager;
import com.ibm.ServerWizard2.ServerWizard2;
import com.ibm.ServerWizard2.controller.TargetWizardController;
-import com.ibm.ServerWizard2.model.Attribute;
import com.ibm.ServerWizard2.model.Connection;
import com.ibm.ServerWizard2.model.ConnectionEndpoint;
import com.ibm.ServerWizard2.model.Field;
import com.ibm.ServerWizard2.model.Target;
+import com.ibm.ServerWizard2.utility.GitProgressMonitor;
+import com.ibm.ServerWizard2.utility.Github;
import com.ibm.ServerWizard2.utility.GithubFile;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.RebaseResult;
+import org.eclipse.jgit.api.ResetCommand;
+import org.eclipse.jgit.api.ResetCommand.ResetType;
+import org.eclipse.jgit.api.StatusCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.api.errors.InvalidRemoteException;
+import org.eclipse.jgit.api.errors.TransportException;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.TextProgressMonitor;
+import org.eclipse.jgit.transport.FetchResult;
+import org.eclipse.jgit.transport.RefSpec;
+
+
+
public class MainDialog extends Dialog {
private TableViewer viewer;
private Tree tree;
@@ -79,6 +97,7 @@ public class MainDialog extends Dialog {
private Button btnDeleteTarget;
private Button btnSave;
private Button btnOpen;
+ private Button btnClone;
private Button btnOpenLib;
private Button btnDeleteConnection;
private Button btnSaveAs;
@@ -169,7 +188,7 @@ public class MainDialog extends Dialog {
buttonRow1 = new Composite(container, SWT.NONE);
GridData gd_buttonRow1 = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
- gd_buttonRow1.widthHint = 789;
+ gd_buttonRow1.widthHint = 850;
buttonRow1.setLayoutData(gd_buttonRow1);
GridLayout rl_buttonRow1 = new GridLayout(18, false);
buttonRow1.setLayout(rl_buttonRow1);
@@ -243,11 +262,11 @@ public class MainDialog extends Dialog {
btnDeleteTarget.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
btnDeleteTarget.setText("Delete Instance");
- btnShowHidden = new Button(compositeInstance, SWT.CHECK);
- GridData gd_btnShowHidden = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
- gd_btnShowHidden.heightHint = 20;
- btnShowHidden.setLayoutData(gd_btnShowHidden);
- btnShowHidden.setText(" Show Hidden");
+ btnShowHidden = new Button(compositeInstance, SWT.CHECK);
+ GridData gd_btnShowHidden = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnShowHidden.heightHint = 20;
+ btnShowHidden.setLayoutData(gd_btnShowHidden);
+ btnShowHidden.setText(" Show Hidden");
btnCopyInstance = new Button(compositeInstance, SWT.NONE);
btnCopyInstance.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
@@ -332,10 +351,8 @@ public class MainDialog extends Dialog {
listBusses = new List(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
this.addEvents();
-
- controller.init();
-
this.setDirtyState(false);
+
// load file if passed on command line
if (!mrwFilename.isEmpty()) {
controller.readXML(mrwFilename);
@@ -345,8 +362,8 @@ public class MainDialog extends Dialog {
cmbBusses.add(t.getType());
cmbBusses.setData(t.getType(), t);
}
+ attributes = new Vector<Field>();
this.initInstanceMode();
- // columnName.setWidth(200);
sashForm.setWeights(new int[] { 1, 1 });
columnName.pack();
@@ -380,12 +397,8 @@ public class MainDialog extends Dialog {
try {
controller.initModel();
setFilename("");
- initAll();
+ initInstanceMode();
setDirtyState(false);
- refreshInstanceTree();
- refreshConnections();
- updateView();
-
} catch (Exception e1) {
e1.printStackTrace();
}
@@ -417,7 +430,7 @@ public class MainDialog extends Dialog {
}
Boolean dirty = controller.readXML(filename);
setFilename(filename);
- initAll();
+ initInstanceMode();
setDirtyState(dirty);
}
});
@@ -481,6 +494,22 @@ public class MainDialog extends Dialog {
gd_sep.widthHint = 30;
label.setLayoutData(gd_sep);
+ btnClone = createButton(row1, IDialogConstants.NO_ID, "Manage Git", false);
+ GridData gd_btnClone = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnClone.widthHint = 90;
+
+ btnClone.setLayoutData(gd_btnClone);
+ btnClone.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnClone.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ GitDialog dlg = new GitDialog(btnClone.getShell());
+ dlg.open();
+ }
+ });
+ btnClone.setToolTipText("Retrieves Library from github");
+
+
btnOpenLib = createButton(row1, IDialogConstants.NO_ID, "Open Lib", false);
GridData gd_btnOpenLib = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_btnOpenLib.widthHint = 90;
@@ -569,11 +598,6 @@ public class MainDialog extends Dialog {
return null;
}
- private void initAll() {
- tabFolder.setSelection(0);
- initInstanceMode();
- }
-
private void initBusMode() {
busMode = true;
this.lblBusDirections.setEnabled(true);
@@ -590,24 +614,24 @@ public class MainDialog extends Dialog {
}
if (cmbCards.getItemCount() > 0) {
cmbCards.select(-1);
- //this.targetForConnections = (Target)cmbCards.getData();
}
for (TreeItem item : tree.getItems()) {
Target target = (Target) item.getData();
- // controller.getRootTarget().hideBusses();
controller.hideBusses(target);
}
-
-
this.source = null;
this.dest = null;
this.selectedEndpoint = null;
refreshInstanceTree();
refreshConnections();
+ attributes.clear();
+ viewer.setInput(attributes);
+ viewer.refresh();
this.updateView();
}
private void initInstanceMode() {
+ tabFolder.setSelection(0);
busMode = false;
this.lblInstanceDirections.setEnabled(true);
this.lblInstanceDirections.setVisible(true);
@@ -618,6 +642,10 @@ public class MainDialog extends Dialog {
this.targetForConnections = null;
this.refreshInstanceTree();
this.listBusses.removeAll();
+ refreshConnections();
+ attributes.clear();
+ viewer.setInput(attributes);
+ viewer.refresh();
this.updateView();
}
@@ -637,6 +665,10 @@ public class MainDialog extends Dialog {
}
}
+ /*
+ * Updates button enabled states based on if target is selected
+ * Also updates attribute table based on selected target
+ */
private void updateView() {
Target targetInstance = getSelectedTarget();
if (targetInstance == null) {
@@ -650,10 +682,13 @@ public class MainDialog extends Dialog {
updatePopupMenu(targetInstance);
updateChildCombo(targetInstance);
+ //A target is selected so show the associated attributes
TreeItem item = tree.getSelection()[0];
ConnectionEndpoint ep = this.getEndpoint(item, null);
- refreshAttributes(targetInstance,ep);
-
+ attributes = controller.getAttributesAndGlobals(targetInstance, "/"+ep.getName());
+ viewer.setInput(attributes);
+ viewer.refresh();
+
if (targetInstance.isSystem()) {
btnDeleteTarget.setEnabled(false);
} else {
@@ -667,7 +702,10 @@ public class MainDialog extends Dialog {
btnDefaults.setEnabled(true);
}
-
+ /*
+ * Creates right-click popup menu for adding connections
+ *
+ */
private void updatePopupMenu(Target selectedTarget) {
if (selectedTarget == null || tree.getSelectionCount()==0) {
return;
@@ -819,36 +857,6 @@ public class MainDialog extends Dialog {
this.setFontStyle(item, SWT.BOLD | SWT.ITALIC, true);
selectedEndpoint = item;
}
-
- private void refreshAttributes(Target targetInstance,ConnectionEndpoint ep) {
- attributes.clear();
- for (Map.Entry<String, Attribute> entry : targetInstance.getAttributes().entrySet()) {
-
- Attribute attribute = entry.getValue();
- if (!attribute.isHidden()) {
- if (attribute.isGlobal() && !controller.getModelCreationMode()) {
- if (ep !=null) {
- String path="/"+ep.getName();
- Field field = controller.getGlobalSetting(path, attribute.name);
- if (field==null) {
- controller.setGlobalSetting(path, attribute.name, "");
- field = controller.getGlobalSetting(path, attribute.name);
- }
- field.type = attribute.getValue().getType();
- if (field.type.equals("enumeration")) {
- field.enumerator = attribute.getValue().getFields().get(0).enumerator;
- }
- attributes.add(field);
- }
- } else {
- for (Field field : attribute.getValue().getFields())
- attributes.add(field);
- }
- }
- }
- viewer.refresh();
- }
-
private void clearTreeAll() {
if (tree.getItemCount() > 0) {
clearTree(tree.getItem(0));
@@ -997,6 +1005,23 @@ public class MainDialog extends Dialog {
}
}
+ private void addConnection(Boolean cabled) {
+ Target busTarget = (Target) cmbBusses.getData(cmbBusses.getText());
+ Connection conn = targetForConnections.addConnection(busTarget, source, dest, cabled);
+ this.addConnection(conn);
+ setDirtyState(true);
+ }
+
+ private void deleteConnection() {
+ if (targetForConnections == null || listBusses.getSelectionCount() == 0) {
+ return;
+ }
+ Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]);
+ controller.deleteConnection(targetForConnections, conn.busTarget, conn);
+ this.refreshConnections();
+ setDirtyState(true);
+ }
+
private void setFontStyle(TreeItem item, int style, boolean selected) {
if (item.isDisposed()) {
return;
@@ -1023,23 +1048,6 @@ public class MainDialog extends Dialog {
return super.close();
}
- private void addConnection(Boolean cabled) {
- Target busTarget = (Target) cmbBusses.getData(cmbBusses.getText());
- Connection conn = targetForConnections.addConnection(busTarget, source, dest, cabled);
- this.addConnection(conn);
- setDirtyState(true);
- }
-
- private void deleteConnection() {
- if (targetForConnections == null || listBusses.getSelectionCount() == 0) {
- return;
- }
- Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]);
- controller.deleteConnection(targetForConnections, conn.busTarget, conn);
- this.refreshConnections();
- setDirtyState(true);
- }
-
public void setDirtyState(Boolean dirty) {
this.dirty = dirty;
if (this.btnSave != null) {
@@ -1196,7 +1204,9 @@ public class MainDialog extends Dialog {
public void widgetSelected(SelectionEvent arg0) {
if (listBusses.getSelectionCount() > 0) {
Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]);
- refreshAttributes(conn.busTarget,null);
+ attributes = controller.getAttributesAndGlobals(conn.busTarget, "");
+ viewer.setInput(attributes);
+ viewer.refresh();
}
}
});
@@ -1288,7 +1298,5 @@ public class MainDialog extends Dialog {
});
viewer.setContentProvider(ArrayContentProvider.getInstance());
- attributes = new Vector<Field>();
- viewer.setInput(attributes);
}
}
OpenPOWER on IntegriCloud