Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
added support for readonly flag on staging areas, used for staging ar…
Browse files Browse the repository at this point in the history
…eas that are only for pre-staged files, i.e. not a workbench project staging destination.

added some fault tolerance for broken remote staging configurations, such that preference pages still load.
  • Loading branch information
gregjan committed Oct 9, 2013
1 parent 97c5c98 commit 928d082
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion staging/initialStagingAreasConfig.json
@@ -1,7 +1,7 @@
{
"stagingAreas":{
"data/":{
"name":"BagIt Data Folder"
"name":"BagIt Data Folder (local only)"
}
},
"customMappings" :{},
Expand Down
14 changes: 12 additions & 2 deletions staging/src/main/java/staging/plugin/views/StagingAreasView.java
Expand Up @@ -65,6 +65,7 @@ public class StagingAreasView extends ViewPart {
private static final int NAME_COL = 0;
private static final int STATUS_COL = 1;
private static final int BASE_URI_COL = 2;
private static final int WRITABLE_COL = 3;

private Action actionReloadConfiguration;
private Action actionConnect;
Expand Down Expand Up @@ -107,6 +108,8 @@ public String getColumnText(Object obj, int index) {
return stage.getURI().toString();
case STATUS_COL:
return stage.isConnected() ? "connected" : "";
case WRITABLE_COL:
return stage.isReadOnly() ? "no" : "yes";
}
return "";
}
Expand Down Expand Up @@ -164,8 +167,8 @@ public void createPartControl(Composite parent) {
}

private void createColumns(Composite parent, ViewLabelProvider labelProvider) {
String[] titles = { "Stage Name", "Base URI", "Status" };
int[] bounds = { 250, 300, 200 };
String[] titles = { "Stage Name", "Base URI", "Status", "Writable" };
int[] bounds = { 250, 300, 200, 200 };

TableViewerColumn col0 = createTableViewerColumn(titles[0], bounds[0], 0);
col0.setLabelProvider(new ColumnLabelProvider() {
Expand Down Expand Up @@ -198,6 +201,13 @@ public String getText(Object element) {
return ((StagingArea)element).getStatus();
}
});
TableViewerColumn col3 = createTableViewerColumn(titles[3], bounds[3], 3);
col3.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((StagingArea)element).isReadOnly() ? "no" : "yes";
}
});
}

public void refreshView() {
Expand Down
Binary file modified staging/staging-areas-0.0.1-SNAPSHOT.jar
Binary file not shown.
Expand Up @@ -92,17 +92,18 @@ public void createControl(Composite parent) {

Stages stages = StagingPlugin.getDefault().getStages();
for (SharedStagingArea area : stages.getAllAreas().values()) {
URL repo = area.getConfigURL();
TableItem add = new TableItem(stageTable, SWT.NULL);
add.setText(0, area.getName());
add.setText(1, repo.getHost());
add.setText(2, area.isConnected() ? "yes" : "no");
add.setData(area);
if (!area.isReadOnly()) {
URL repo = area.getConfigURL();
TableItem add = new TableItem(stageTable, SWT.NULL);
add.setText(0, area.getName());
add.setText(1, repo.getHost());
add.setText(2, area.isConnected() ? "yes" : "no");
add.setData(area);
}
}
cUri.pack();
cName.pack();
cConn.pack();


stageTable.addSelectionListener(new SelectionListener() {
@Override
Expand Down Expand Up @@ -150,22 +151,26 @@ private void stageSelectionChanged() {
this.stagingArea = (SharedStagingArea) stageTable.getSelection()[0]
.getData();
if (!this.stagingArea.isConnected()) {
StagingPlugin.getDefault().getStages().connect(this.stagingArea.getURI());
StagingPlugin.getDefault().getStages()
.connect(this.stagingArea.getURI());
}
URI projectManifestBase = null;
if(!this.stagingArea.getURI().isAbsolute()) {
if (!this.stagingArea.getURI().isAbsolute()) {
projectManifestBase = this.stagingArea.makeURI("");
} else {
projectManifestBase = this.stagingArea.makeURI(mainPage.getProjectName());
projectManifestBase = this.stagingArea.makeURI(mainPage
.getProjectName());
}
manifestReferencesText.setText(projectManifestBase.toString());
if (this.stagingArea.isConnected()) {
try {
URI projectStagedBase = this.stagingArea.getStorageURI(projectManifestBase);
URI projectStagedBase = this.stagingArea
.getStorageURI(projectManifestBase);
stageText.setText(projectStagedBase.toString());
this.setPageComplete(this.stagingArea != null);
} catch (StagingException e) {
stageText.setText("Cannot connect to this staging area: "+e.getMessage());
stageText.setText("Cannot connect to this staging area: "
+ e.getMessage());
}
} else {
stageText.setText("Cannot connect to this staging area");
Expand Down
Expand Up @@ -55,7 +55,8 @@ public void fill(Menu menu, int index) {
submenuitem.setMenu (subMenu);

for(Entry<URI, SharedStagingArea> area : StagingPlugin.getDefault().getStages().getAllAreas().entrySet()) {
addStageMenuItem(area.getValue(), subMenu, mpn);
if(!area.getValue().isReadOnly())
addStageMenuItem(area.getValue(), subMenu, mpn);
}
}

Expand Down

0 comments on commit 928d082

Please sign in to comment.