Permalink
Browse files

made all labels and decor sensitive to changes, they will refresh on …

…stage/capture/delete operations now

removed the describe package, moving single command class to the command package
renamed OriginalsDecorator b/c it also decorates the Divs in arrangement
  • Loading branch information...
1 parent 2214530 commit 0b4a99340ac07b31c3fd60d0fea9a3adb24c2cd3 @gregjan gregjan committed Jul 25, 2012
View
366 irods-efs.plugin/src/irods/efs/plugin/LoginInputDialog.java
@@ -41,218 +41,218 @@
/**
* @author Gregory Jansen
- *
+ *
*/
public class LoginInputDialog extends TitleAreaDialog {
- String message;
- URI irodsURI;
- String zone;
- String defaultUsername;
- Text textUsername;
- Text textPassword;
- Shell shell = null;
+ String message;
+ URI irodsURI;
+ String zone;
+ String defaultUsername;
+ Text textUsername;
+ Text textPassword;
+ Shell shell = null;
- Button okButton;
+ Button okButton;
- String username = null;
- String password = null;
+ String username = null;
+ String password = null;
- /**
- * @param parentShell
- */
- protected LoginInputDialog(Shell parentShell, String message, URI irodsURI, String defaultUsername, String zone) {
- super(parentShell);
- this.message = message;
- this.irodsURI = irodsURI;
- this.defaultUsername = defaultUsername;
- this.textPassword = null;
- this.textUsername = null;
- this.zone = zone;
- }
+ /**
+ * @param parentShell
+ */
+ protected LoginInputDialog(Shell parentShell, String message, URI irodsURI, String defaultUsername, String zone) {
+ super(parentShell);
+ this.message = message;
+ this.irodsURI = irodsURI;
+ this.defaultUsername = defaultUsername;
+ this.textPassword = null;
+ this.textUsername = null;
+ this.zone = zone;
+ }
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- createControls(composite);
- // add controls to composite as necessary
- return composite;
- }
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ createControls(composite);
+ // add controls to composite as necessary
+ return composite;
+ }
- /**
- * @param composite
- */
- private void createControls(Composite composite) {
- shell = composite.getShell();
- shell.setText("iRODS Authentication");
+ /**
+ * @param composite
+ */
+ private void createControls(Composite composite) {
+ shell = composite.getShell();
+ shell.setText("iRODS Authentication");
- this.setMessage(message);
- Group group = new Group(composite, SWT.None);
- group.setText("");
+ this.setMessage(message);
+ Group group = new Group(composite, SWT.None);
+ group.setText("");
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.setLayout(new GridLayout(2, true));
- Label grid = new Label(group, SWT.None);
- grid.setText("Location");
- Text gridText = new Text(group,SWT.BORDER);
- gridText.setText(irodsURI.toString());
- gridText.setEnabled(false);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ group.setLayout(new GridLayout(2, true));
+ Label grid = new Label(group, SWT.None);
+ grid.setText("Location");
+ Text gridText = new Text(group, SWT.BORDER);
+ gridText.setText(irodsURI.toString());
+ gridText.setEnabled(false);
- Label userId = new Label(group, SWT.None);
- userId.setText("Username");
+ Label userId = new Label(group, SWT.None);
+ userId.setText("Username");
- textUsername = new Text(group,SWT.BORDER);
- if(this.defaultUsername != null && !this.defaultUsername.isEmpty()) {
- textUsername.setText(this.defaultUsername);
- textUsername.setEditable(false);
- }
- textUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ textUsername = new Text(group, SWT.BORDER);
+ if (this.defaultUsername != null && !this.defaultUsername.isEmpty()) {
+ textUsername.setText(this.defaultUsername);
+ textUsername.setEditable(false);
+ }
+ textUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Label userPsw = new Label(group, SWT.None);
- userPsw.setText("Password");
+ Label userPsw = new Label(group, SWT.None);
+ userPsw.setText("Password");
- textPassword = new Text(group,SWT.PASSWORD |SWT.BORDER);
- textPassword.setText("");
- textPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ textPassword = new Text(group, SWT.PASSWORD | SWT.BORDER);
+ textPassword.setText("");
+ textPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.pack();
- composite.pack();
- }
+ group.pack();
+ composite.pack();
+ }
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalSpan = 3;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.CENTER;
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ GridData gridData = new GridData();
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalSpan = 3;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.horizontalAlignment = SWT.CENTER;
- parent.setLayoutData(gridData);
- // Create Add button
- // Own method as we need to overview the SelectionAdapter
- createOkButton(parent, OK, "Okay", true);
+ parent.setLayoutData(gridData);
+ // Create Add button
+ // Own method as we need to overview the SelectionAdapter
+ createOkButton(parent, OK, "Okay", true);
- // Create Cancel button
- Button cancelButton = createButton(parent, CANCEL, "Cancel", false);
+ // Create Cancel button
+ Button cancelButton = createButton(parent, CANCEL, "Cancel", false);
- // Add a SelectionListener
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setReturnCode(CANCEL);
- close();
- }
- });
+ // Add a SelectionListener
+ cancelButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setReturnCode(CANCEL);
+ close();
+ }
+ });
- // Create Test button
- Button testButton = createButton(parent, IDialogConstants.PROCEED_ID, "Test", false);
+ // Create Test button
+ Button testButton = createButton(parent, IDialogConstants.PROCEED_ID, "Test", false);
- // Add a SelectionListener
- testButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (validFormInputs()) {
- IRODSAccount account = makeAccount();
- testConnection(account);
- }
- }
- });
- }
+ // Add a SelectionListener
+ testButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (validFormInputs()) {
+ IRODSAccount account = makeAccount();
+ testConnection(account);
+ }
+ }
+ });
+ }
- /**
- * @return
- */
- protected IRODSAccount makeAccount() {
- IRODSAccount result = new IRODSAccount(this.irodsURI.getHost(), this.irodsURI.getPort(), textUsername.getText(), textPassword.getText(),"",zone, "fake");
- return result;
- }
+ /**
+ * @return
+ */
+ protected IRODSAccount makeAccount() {
+ IRODSAccount result = new IRODSAccount(this.irodsURI.getHost(), this.irodsURI.getPort(), textUsername.getText(),
+ textPassword.getText(), "", zone, "fake");
+ return result;
+ }
- /**
- * @return
- */
- protected boolean validFormInputs() {
- return textPassword.getText() != null && !textPassword.getText().isEmpty() && textUsername.getText() != null
- && !textUsername.getText().isEmpty();
- }
+ /**
+ * @return
+ */
+ protected boolean validFormInputs() {
+ return textPassword.getText() != null && !textPassword.getText().isEmpty() && textUsername.getText() != null
+ && !textUsername.getText().isEmpty();
+ }
- /**
- * @param parent
- * @param ok
- * @param string
- * @param b
- */
- private Button createOkButton(Composite parent, int ok, String string, boolean defaultButton) {
- // increment the number of columns in the button bar
- ((GridLayout) parent.getLayout()).numColumns++;
- okButton = new Button(parent, SWT.PUSH);
- okButton.setEnabled(false);
- okButton.setText(string);
- // button.setFont(JFaceResources.getDialogFont());
- // button.setData(new Integer(id));
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- okPressed();
- }
- });
- if (defaultButton) {
- Shell shell = parent.getShell();
- if (shell != null) {
- shell.setDefaultButton(okButton);
- }
+ /**
+ * @param parent
+ * @param ok
+ * @param string
+ * @param b
+ */
+ private Button createOkButton(Composite parent, int ok, String string, boolean defaultButton) {
+ // increment the number of columns in the button bar
+ ((GridLayout) parent.getLayout()).numColumns++;
+ okButton = new Button(parent, SWT.PUSH);
+ okButton.setEnabled(false);
+ okButton.setText(string);
+ // button.setFont(JFaceResources.getDialogFont());
+ // button.setData(new Integer(id));
+ okButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ okPressed();
+ }
+ });
+ if (defaultButton) {
+ Shell shell = parent.getShell();
+ if (shell != null) {
+ shell.setDefaultButton(okButton);
+ }
+ }
+ setButtonLayoutData(okButton);
+ return okButton;
}
- setButtonLayoutData(okButton);
- return okButton;
- }
- @Override
- protected void okPressed() {
- this.username = this.textUsername.getText();
- this.password = this.textPassword.getText();
- super.okPressed();
- }
+ @Override
+ protected void okPressed() {
+ this.username = this.textUsername.getText();
+ this.password = this.textPassword.getText();
+ super.okPressed();
+ }
- public String getUsername() {
- return username;
- }
+ public String getUsername() {
+ return username;
+ }
- public String getPassword() {
- return password;
- }
+ public String getPassword() {
+ return password;
+ }
- private boolean testConnection(IRODSAccount account) {
- boolean result = false;
- try {
- IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance();
- IRODSFileFactory ff = irodsFileSystem.getIRODSFileFactory(account);
- String testPath = "/lakjsdf/asdfl/asdf/thispathisgarbage";
- //System.out.println("testing path:"+testPath);
- IRODSFile file = ff.instanceIRODSFile(testPath);
+ private boolean testConnection(IRODSAccount account) {
+ boolean result = false;
+ try {
+ IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance();
+ IRODSFileFactory ff = irodsFileSystem.getIRODSFileFactory(account);
+ String testPath = "/lakjsdf/asdfl/asdf/thispathisgarbage";
+ // System.out.println("testing path:"+testPath);
+ IRODSFile file = ff.instanceIRODSFile(testPath);
- file.exists();
- result = true;
- setMessage("Connection succeeded.",
- IMessageProvider.INFORMATION);
- } catch (JargonException e) {
- String msg = null;
- if (e.getCause() != null) {
- msg = e.getCause().getLocalizedMessage();
- } else {
- msg = e.getLocalizedMessage();
- }
- if(msg.contains("826000")) {
- setMessage("Connection failed: Bad username or password.", IMessageProvider.ERROR);
- } else {
- setMessage("Connection failed due to an error: " + msg, IMessageProvider.ERROR);
- }
- }
- if (result) {
- setMessage("Connection succeeded", IMessageProvider.INFORMATION);
- this.okButton.setEnabled(true);
- } else {
- this.okButton.setEnabled(false);
+ file.exists();
+ result = true;
+ setMessage("Connection succeeded.", IMessageProvider.INFORMATION);
+ } catch (JargonException e) {
+ String msg = null;
+ if (e.getCause() != null) {
+ msg = e.getCause().getLocalizedMessage();
+ } else {
+ msg = e.getLocalizedMessage();
+ }
+ if (msg.contains("826000")) {
+ setMessage("Connection failed: Bad username or password.", IMessageProvider.ERROR);
+ } else {
+ setMessage("Connection failed due to an error: " + msg, IMessageProvider.ERROR);
+ }
+ }
+ if (result) {
+ setMessage("Connection succeeded", IMessageProvider.INFORMATION);
+ this.okButton.setEnabled(true);
+ } else {
+ this.okButton.setEnabled(false);
+ }
+ return result;
}
- return result;
- }
}
View
1 workbench_plugin/META-INF/MANIFEST.MF
@@ -109,7 +109,6 @@ Export-Package: .,
unc.lib.cdr.workbench.arrange,
unc.lib.cdr.workbench.capture,
unc.lib.cdr.workbench.commands,
- unc.lib.cdr.workbench.describe,
unc.lib.cdr.workbench.originals,
unc.lib.cdr.workbench.preferences,
unc.lib.cdr.workbench.project,
View
9 workbench_plugin/plugin.xml
@@ -90,7 +90,7 @@
name="Rename Div">
</command>
<command
- defaultHandler="unc.lib.cdr.workbench.describe.EditDescriptionCommand"
+ defaultHandler="unc.lib.cdr.workbench.commands.EditDescriptionCommand"
id="cdr-workbench.commandEditDescription"
name="Edit Description (MODS)">
</command>
@@ -709,7 +709,7 @@
<iterate>
<or>
<instanceof
- value="unc.lib.cdr.workbench.arrange.ArrangementProjectElement">
+ value="org.eclipse.core.resources.IFolder">
</instanceof>
<and>
<instanceof
@@ -719,6 +719,9 @@
property="workbench_plugin.projectPropertyTester.open">
</test>
</and>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
</or>
</iterate>
</with>
@@ -1316,7 +1319,7 @@
<extension
point="org.eclipse.ui.decorators">
<decorator
- class="unc.lib.cdr.workbench.capture.OriginalsDecorator"
+ class="unc.lib.cdr.workbench.views.OriginalAndDivDecorator"
id="cdr-workbench.decoratorCaptured"
label="Originals Decorator"
lightweight="true"
View
96 workbench_plugin/src/main/java/unc/lib/cdr/workbench/arrange/ArrangementLabelProvider.java
@@ -16,68 +16,54 @@
package unc.lib.cdr.workbench.arrange;
import gov.loc.mets.DivType;
-import gov.loc.mets.provider.MetsItemProviderAdapterFactory;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
-import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import unc.lib.cdr.workbench.project.ICustomEObjectBucket;
+import unc.lib.cdr.workbench.project.MetsProjectNature;
import unc.lib.cdr.workbench.views.LabelImageFactory;
-public class ArrangementLabelProvider extends AdapterFactoryLabelProvider {
+public class ArrangementLabelProvider extends AdapterFactoryLabelProvider implements INotifyChangedListener {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(ArrangementLabelProvider.class);
private DecoratingLabelProvider provider = (DecoratingLabelProvider) WorkbenchLabelProvider
.getDecoratingWorkbenchLabelProvider();
- // private ComposedAdapterFactory metsAdapterFactory = MetsProjectNature.getAdapterFactory();
- // private Set<ILabelProviderListener> listeners = new HashSet<ILabelProviderListener>();
-
- private static AdapterFactory adapterFactory;
-
- static {
- adapterFactory = new ComposedAdapterFactory(new AdapterFactory[] { new ResourceItemProviderAdapterFactory(),
- new MetsItemProviderAdapterFactory(), new ReflectiveItemProviderAdapterFactory() });
- }
/**
*
*/
public ArrangementLabelProvider() {
- super(adapterFactory);
- // metsAdapterFactory.addListener(this);
+ super(MetsProjectNature.getAdapterFactory());
}
- // @Override
- // public void addListener(ILabelProviderListener listener) {
- // this.listeners.add(listener);
- // this.provider.addListener(listener);
- // }
-
- // @Override
- // public void dispose() {
- // super.dispose();
- // }
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ super.addListener(listener);
+ this.provider.addListener(listener);
+ }
- // @Override
- // public boolean isLabelProperty(Object element, String property) {
- // return super.isLabelProperty(element, property);
- // }
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
- // @Override
- // public void removeListener(ILabelProviderListener listener) {
- // this.listeners.remove(listener);
- // this.provider.removeListener(listener);
- // }
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ super.removeListener(listener);
+ this.provider.removeListener(listener);
+ }
/*
* (non-Javadoc)
@@ -90,13 +76,6 @@ public Image getImage(Object element) {
if (result == null)
result = super.getImage(element);
- // if (element instanceof DivType) {
- // DivType d = (DivType) element;
- // Object adapted = Platform.getAdapterManager().getAdapter(d, IResource.class);
- // if (adapted != null) {
- // IResource r = (IResource) adapted;
- // }
- // }
if (result == null)
result = LabelImageFactory.getImageForObject(element);
return result;
@@ -118,14 +97,6 @@ public String getText(Object element) {
} else {
return super.getText(element);
}
- /*
- * if (result == null && element instanceof DivType) { DivType d = (DivType) element; result = d.getLABEL1();
- * //Object adapted = Platform.getAdapterManager().getAdapter(d, IResource.class); //if (adapted != null) {
- * //IResource r = (IResource) adapted; //} } else
- */
-
- // return result;
- // return provider.getLabelDecorator().decorateText(result, element);
}
/*
@@ -134,16 +105,15 @@ public String getText(Object element) {
* @see org.eclipse.emf.edit.provider.INotifyChangedListener#notifyChanged(org
* .eclipse.emf.common.notify.Notification)
*/
- // @Override
- // public void notifyChanged(Notification notification) {
- // // LOG.debug("notified of model change in "+notification.getNotifier());
- // final LabelProviderChangedEvent e = new LabelProviderChangedEvent(this, notification.getNotifier());
- // Display.getDefault().asyncExec(new Runnable() {
- // public void run() {
- // for (ILabelProviderListener l : listeners) {
- // l.labelProviderChanged(e);
- // }
- // }
- // });
- // }
+ @Override
+ public void notifyChanged(Notification notification) {
+ final LabelProviderChangedEvent e = new LabelProviderChangedEvent(this, notification.getNotifier());
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ for (ILabelProviderListener l : labelProviderListeners) {
+ l.labelProviderChanged(e);
+ }
+ }
+ });
+ }
}
View
2 ...ench/describe/EditDescriptionCommand.java → ...ench/commands/EditDescriptionCommand.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package unc.lib.cdr.workbench.describe;
+package unc.lib.cdr.workbench.commands;
import gov.loc.mets.DivType;
import gov.loc.mets.MDTYPEType;
View
8 ...workbench/capture/OriginalsDecorator.java → ...kbench/views/OriginalAndDivDecorator.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package unc.lib.cdr.workbench.capture;
+package unc.lib.cdr.workbench.views;
import gov.loc.mets.DivType;
import gov.loc.mets.MdSecType;
@@ -40,15 +40,15 @@
import unc.lib.cdr.workbench.originals.OriginalStub;
import unc.lib.cdr.workbench.views.LabelImageFactory.Icon;
-public class OriginalsDecorator implements ILightweightLabelDecorator {
+public class OriginalAndDivDecorator implements ILightweightLabelDecorator {
Set<ILabelProviderListener> listeners = new HashSet<ILabelProviderListener>();
- public OriginalsDecorator() {
+ public OriginalAndDivDecorator() {
// TODO register as listener to capture and staging changes (less granular this time)
}
@SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(OriginalsDecorator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(OriginalAndDivDecorator.class);
@Override
public void addListener(ILabelProviderListener listener) {

0 comments on commit 0b4a993

Please sign in to comment.