Permalink
Browse files

Context menu options to show DS-Matrix were configured.

  • Loading branch information...
1 parent 4d1547c commit e7ff525ccec316eebb76a4e2594f7313641348d8 @daniilyar daniilyar committed Mar 2, 2012
View
@@ -50,23 +50,22 @@
</page>
</extension>
- <!-- Popupmenu action to check selected resources (files/packages/jars) on demand in packages scope -->
+
+ <!-- Popupmenu action to check selected projects on demand in packages scope -->
<extension point="org.eclipse.ui.popupMenus">
- <objectContribution
- objectClass="org.eclipse.core.resources.IResource"
+ <objectContribution objectClass="org.eclipse.core.resources.IResource"
adaptable="true"
id="Run DSM on project">
-
+
<visibility>
- <objectClass name="org.eclipse.core.resources.IResource"/>
+ <objectClass name="org.eclipse.core.resources.IProject"/>
</visibility>
<menu
id="DSM Viewer menu"
label="DSM Viewer menu"
path="additions">
- <separator
- name="xbatch"/>
+ <separator name="xbatch"/>
</menu>
<action
label="Show packages DS-Matrix"
@@ -77,22 +76,21 @@
id="Run DSM on resource"/>
</objectContribution>
- <!-- Popupmenu action to check selected resources (files/packages/jars) on demand in classes scope -->
- <objectContribution
- objectClass="org.eclipse.core.resources.IResource"
+
+ <!-- Popupmenu action to check selected projects on demand in classes scope -->
+ <objectContribution objectClass="org.eclipse.core.resources.IResource"
adaptable="true"
id="Run DSM on project">
<visibility>
- <objectClass name="org.eclipse.core.resources.IResource"/>
+ <objectClass name="org.eclipse.core.resources.IProject"/>
</visibility>
<menu
id="DSM Viewer menu"
label="DSM Viewer menu"
path="additions">
- <separator
- name="xbatch"/>
+ <separator name="xbatch"/>
</menu>
<action
label="Show classes DS-Matrix"
@@ -102,35 +100,49 @@
tooltip="classes"
id="Run DSM on resource"/>
</objectContribution>
-
- <!-- Popupmenu action to check selected jars on demand
- <objectContribution
- objectClass="org.eclipse.core.resources.IFile"
- adaptable="true"
- id="1">
- <visibility>
- <or>
- <objectClass name="org.eclipse.jdt.core.ICompilationUnit"/>
- <objectClass name="org.eclipse.jdt.core.IType"/>
- <and>
- <objectClass name="org.eclipse.core.resources.IFile"/>
- <objectState name="extension" value="jar"/>
- </and>
- </or>
- </visibility>
- <action
- label="Show library DS matrix"
- class="com.dsmviewer.dtangler.DtanglerRunner"
- enablesFor="1"
- menubarPath="additions"
- tooltip="Show library DS matrix"
- id="jarFile DtanglerRunner">
- <selection
- name="*.jar"
- class="org.eclipse.core.resources.IFile"/>
- </action>
- </objectContribution>
- -->
+
+
+ <!-- Popupmenu action to check selected jars on demand -->
+ <objectContribution objectClass="org.eclipse.core.resources.IFile" adaptable="true" id="1">
+ <visibility>
+ <or>
+ <objectClass name="org.eclipse.jdt.core.ICompilationUnit"/>
+ <objectClass name="org.eclipse.jdt.core.IType"/>
+ <and>
+ <objectClass name="org.eclipse.core.resources.IFile"/>
+ <objectState name="extension" value="jar"/>
+ </and>
+ </or>
+ </visibility>
+
+ <action label="Show library classes DS matrix" class="com.dsmviewer.dtangler.DtanglerRunner"
+ enablesFor="1"
+ menubarPath="additions"
+ tooltip="classes"
+ id="jarFile DtanglerRunner">
+ <selection name="*.jar" class="org.eclipse.core.resources.IFile"/>
+ </action>
+ </objectContribution>
+
+ <objectContribution objectClass="org.eclipse.core.resources.IFile" adaptable="true" id="2">
+ <visibility>
+ <or>
+ <objectClass name="org.eclipse.jdt.core.ICompilationUnit"/>
+ <objectClass name="org.eclipse.jdt.core.IType"/>
+ <and>
+ <objectClass name="org.eclipse.core.resources.IFile"/>
+ <objectState name="extension" value="jar"/>
+ </and>
+ </or>
+ </visibility>
+ <action label="Show library packages DS matrix" class="com.dsmviewer.dtangler.DtanglerRunner"
+ enablesFor="1"
+ menubarPath="additions"
+ tooltip="packages"
+ id="jarFile DtanglerRunner">
+ <selection name="*.jar" class="org.eclipse.core.resources.IFile"/>
+ </action>
+ </objectContribution>
</extension>
@@ -51,6 +51,7 @@ public void setActivePart(final IAction arg0, final IWorkbenchPart arg1) {
*/
public void selectionChanged(final IAction action, final ISelection selectionData) {
selection = (IStructuredSelection) selectionData;
+ logger.debug("Package Explorer selection was changed to "+ ((IResource)selection.getFirstElement()).getClass().toString());
}
/**
@@ -59,19 +60,18 @@ public void selectionChanged(final IAction action, final ISelection selectionDat
* {@inheritDoc}
*/
public void run(final IAction action) {
-
- System.out.println(action.getDescription());
-
+
try {
List<String> pathList = getPathList(selection);
- String scope = action.getDescription();
-
- Arguments arguments = DtanglerArguments.build(pathList, scope, false);
- DSMatrix dsMatrix = run(arguments);
- DSMView.getTableViewer().setInput(dsMatrix.getRows());
-
+ String scope = action.getDescription(); // "classes" / "packages"
+
+ Arguments arguments = DtanglerArguments.build(pathList, scope, false);
+
+ DSMatrix dsMatrix = computeDsMatrix(arguments);
+ DSMView.getTableViewer().showDSMatrix(dsMatrix);
+
} catch (MissingArgumentsException e) {
e.printStackTrace(); // wrong arguments
DSMView.showErrorMessage(e.getMessage());
@@ -91,10 +91,10 @@ public void run(final IAction action) {
* @throws MissingArgumentsException
* if the request parameters are incorrect.
*/
- public DSMatrix run(Arguments arguments) {
-
+ public DSMatrix computeDsMatrix(Arguments arguments) {
+
DSMatrix dsMatrix;
-
+
try {
logger.info("Dtangler analisys started.");
@@ -121,7 +121,7 @@ public DSMatrix run(Arguments arguments) {
} catch (DtException e) {
throw e;
}
-
+
return dsMatrix;
}
@@ -151,7 +151,7 @@ private String getFullPath(IResource resource) {
IResource resource = (IResource) selectedResource;
String resourcePath = getFullPath(resource);
pathList.add(resourcePath);
- System.out.println(resourcePath);
+ logger.debug("Added to analysis:" + resourcePath);
}
return pathList;
}
@@ -0,0 +1,79 @@
+package com.dsmviewer.ui.views;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dtangler.core.dsm.DsmRow;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import com.dsmviewer.dtangler.DSMatrix;
+
+public class DSMTableViewer extends TableViewer {
+
+ private List<TableViewerColumn> columns = new ArrayList<TableViewerColumn>();
+
+ public DSMTableViewer(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ public void showDSMatrix(DSMatrix dsMatrix) {
+ removeAllColumns();
+ composeColumns(dsMatrix);
+
+ setInput(dsMatrix.getRows());
+ }
+
+ private void removeAllColumns(){
+ for(TableViewerColumn column: columns){
+ column.getColumn().dispose();
+ }
+ columns.clear();
+ }
+
+ private void composeColumns(DSMatrix dsMatrix) {
+ TableViewerColumn nameColumn = createTableViewerColumn("Names: ", 200, true);
+ this.columns.add(nameColumn);
+ nameColumn.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ DsmRow dsmRow = (DsmRow) element;
+ return dsmRow.getDependee().getDisplayName();
+ }
+ });
+
+ for (int i = 1; i <= dsMatrix.getSize(); i++) {
+ // save the column number to set column headers later.
+ dsMatrix.getRows().get(i-1).getDependee().setContentCount(i);
+ TableViewerColumn matrixColumn = createTableViewerColumn("" + i, 35, true);
+ this.columns.add(matrixColumn);
+ matrixColumn.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ DsmRow dsmRow = (DsmRow) element;
+ return Integer.toString(dsmRow.getCells().get(0).getDependencyWeight());
+ }
+ });
+ }
+ }
+
+
+ private TableViewerColumn createTableViewerColumn(String title, int bound, boolean isResizable) {
+ final TableViewerColumn viewerColumn = new TableViewerColumn(this, SWT.NONE);
+ final TableColumn column = viewerColumn.getColumn();
+ column.setText(title);
+ column.setWidth(bound);
+ column.setResizable(isResizable);
+ column.setMoveable(false);
+ return viewerColumn;
+ }
+
+ public List<TableViewerColumn> getColumns(){
+ return this.columns;
+ }
+
+}
Oops, something went wrong.

0 comments on commit e7ff525

Please sign in to comment.