Java R Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
EICS16
IST
data
examples
sources
.gitignore
LICENSE
README.md

README.md

InspectorGuidget

A tool to detect GUI design smells such as blob listeners in java SWING/AWT/JavaFX GUI listeners by raising warnings in the Eclipse Java editor.

The latest version of the paper on Blob Listener is here: https://hal.archives-ouvertes.fr/hal-01499106

How to run InspectorGuidget:

  1. Put the eclipse jar plugin located in https://github.com/diverse-project/InspectorGuidget/blob/master/IST/ and put it in the plugin folder of your Eclipe.
  2. Restart your Eclipse.
  3. Right click on a Java project, a menu InspectorGuidget should appear.
  4. Launch the analysis you want. The results of an analysis should pop up in a dedicated panel. The Eclipse plugin cannot refactor Blob Listener instances. To do so, use the Java project.

How to build InspectorGuidget:

  1. Build the project inspectorguidget.core using maven (mvn package). This project can be used to directly analyse GUI code as illustrated in inspectorguidget.core/src/test/java/fr/inria/diverse/torgen/inspectorguidget/xp/.
  2. Copy the core-1.0-SNAPSHOT-jar-with-dependencies.jar file prouced in the target folder of inspectorguidget.core and paste it into the folder lib of the project inspectorguidget.eclipse.
  3. In Eclipse, import the project inspectorguidget.eclipse to build a Eclipse plugin.

Examples of Blob Listeners GUI toolkits

Swing

public class MenuListener implements ActionListener, CaretListener {
 //...
 protected boolean selectedText;

@Override public void actionPerformed(ActionEvent e) {
  Object src = e.getSource();
  if(src instanceof JMenuItem || src instanceof JButton){
		 String cmd = e.getActionCommand();
		 if(cmd.equals("Copy")){
			 if(selectedText)
				 output.copy();
		 }else if(cmd.equals("Cut")){
			  output.cut();
		 }else if(cmd.equals("Paste")){
			 output.paste();
		 }
		 // etc.
		}
  }
  @Override public void caretUpdate(CaretEvent e){
   	selectedText = e.getDot() != e.getMark();
   	updateStateOfMenus(selectedText);	
 }
}
public void actionPerformed(ActionEvent event) {
   if(event.getSource() == view.moveDown) {
      //...
   } else if(event.getSource() == view.moveLeft) {
      //...
   } else if(event.getSource() == view.moveRight) {
      //...
   } else if(event.getSource() == view.moveUp) {
      //...
   } else if(event.getSource() == view.zoomIn) {
      //...
   } else if(event.getSource() == view.zoomOut) {
      //...
   }
}
public void actionPerformed(ActionEvent evt) {
   Object target = evt.getSource();
   if (target instanceof JButton) {
      //...
   } else if (target instanceof JTextField) {
      //...
   } else if (target instanceof JCheckBox) {
      //...
   } else if (target instanceof JComboBox) {
      //...
   }
}

SWT

public class SelectionEventListener extends AbstractListener implements Listener {
	private int selectMethod;
	
	@Override public void handleEvent(Event event) {
		if (event.type == SWT.MouseDown){
			handleMouse(event);
			return;
		}
		if (!checkCreate(event)) return;
		AbstractAction action = null;

		if (event.widget instanceof MenuItem){
			action = new SimpleSelectionAction(event.type);
			
		} else if (event.widget instanceof ToolItem){
			System.out.println("tool");
			
		} else if (event.widget instanceof Text){
			System.out.println("text");
			
		} else if (event.widget instanceof Button){
			action = new SimpleSelectionAction(event.type);
			action.setShell(((Button) event.widget).getShell());

		} else if (event.widget instanceof Tree){
			StringBuilder sb = new StringBuilder();
			Tree tr = (Tree) event.widget;
			System.out.println("tree");
			//do not handle events of workbench window 
			
			if ((!(tr.getShell() == PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell())) ||
					selectMethod == 3){
				System.out.println("the shell "+tr.getShell());
				TreeItem[] items = ((Tree) event.widget).getSelection();

				for (TreeItem item : items){
					//System.out.println("tree item "+ item.toString());
					sb.append(item.getText());
					TreeItem selected = item;

					while(selected.getParentItem() != null){
						TreeItem parentIt = selected.getParentItem();
						//System.out.println(parentIt);
						sb.insert(0, "/");
						sb.insert(0, parentIt.getText());
						selected = parentIt;
					}
				}
				System.out.println(sb.toString());
				action = new SelectionAction(event.type);
				action.process(event);
				interactionHistory.addInteraction(action);
			}
			return;
		}
		
		else if (event.widget instanceof Table){
			System.out.println("table");
			if (event.detail == SWT.CHECK)
				System.out.println("check");
			String type = event.type == SWT.DefaultSelection ? SelectionAction.DEFAULT_SELECT : SelectionAction.ITEM_SELECT;
			action = new SelectionAction(event.type);
			((SelectionAction) action).addPart(DeliasUtils.getActivePartTitle());
		}
        ...

source cache

    @Override
    public void handleEvent(Event event) {
        if (!(event.widget instanceof Button)){
            return;
        }
        Button b = (Button) event.widget;
        if (b.getText().equals(addButtonText)) {
            add();
        } else if (b.getText().equalsIgnoreCase(removeButtonText)) {
            remove();
        }
    }

source cache

GWT

	@Override
	public void onClick(ClickEvent event) {
		if (event.getSource() == clearDatastoreButton) {
			clearDatastore();
		} else if (event.getSource() == populateDatastoreButton) {
			populateDatastore();
		} else if (event.getSource() == getPopulateDatastoreCountButton) {
			getPopulateDatastoreCount();
		} else if (event.getSource() == refreshEditModeOn) {
			refreshEditMode(true);
		} else if (event.getSource() == refreshEditModeOff) {
			refreshEditMode(false);
		} else if (event.getSource() == emailOpenedTree) {
			emailOpenedTree();
		} else if (event.getSource() == showOpenedTree) {
			showOpenedTree();
		}
	}

source cache