Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call number action #1698

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ganttproject/data/resources/icons/call_number_16.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ganttproject/data/resources/xslt/gantt-resources.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<td valign="top"><b><xsl:value-of select="name"/></b></td>
<td valign="top"><xsl:value-of select="role"/></td>
<td valign="top"><a><xsl:attribute name="href">mailto:<xsl:value-of select="mail"/></xsl:attribute><xsl:value-of select="mail"/></a></td>
<td valign="top"><xsl:value-of select="phone"/></td>
<td valign="top"><a><xsl:attribute name="href">tel:<xsl:value-of select="translate(phone, ' ', '')"/></xsl:attribute><xsl:value-of select="phone"/></a></td>
</tr>
</xsl:for-each>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ public void changeValue(ChangeValueEvent event) {
mHuman.add(a);
}
mHuman.add(myResourceActions.getResourceSendMailAction());
mHuman.add(myResourceActions.getResourceCallNumberAction());
bar.add(mHuman);

HelpMenu helpMenu = new HelpMenu(getProject(), getUIFacade(), getProjectUIFacade());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ private void createPopupMenu(MouseEvent e) {
menu.add(resourceActions[i]);
}
menu.add(myResourceActionSet.getResourceSendMailAction());
menu.add(myResourceActionSet.getResourceCallNumberAction());
menu.addSeparator();
menu.add(myResourceActionSet.getResourceMoveUpAction());
menu.add(myResourceActionSet.getResourceMoveDownAction());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class ResourceActionSet {

private final ResourceSendMailAction myResourceSendMailAction;

private final ResourceCallNumberAction myResourceCallNumberAction;

private final AssignmentDeleteAction myAssignmentDelete;

private AbstractAction[] myActions;
Expand All @@ -53,6 +55,7 @@ public ResourceActionSet(ResourceContext resourceContext, AssignmentContext assi
myResourceMoveUpAction = new ResourceMoveUpAction(table);
myResourceMoveDownAction = new ResourceMoveDownAction(table);
myResourceSendMailAction = new ResourceSendMailAction(table);
myResourceCallNumberAction = new ResourceCallNumberAction(table);
myAssignmentDelete = new AssignmentDeleteAction(assignmentContext, uiFacade);
}

Expand All @@ -61,6 +64,7 @@ public AbstractAction[] getActions() {
myResourceNewAction.putValue(Action.SHORT_DESCRIPTION, null);
myResourcePropertiesAction.putValue(Action.SHORT_DESCRIPTION, null);
myResourceSendMailAction.putValue(Action.SHORT_DESCRIPTION, null);
myResourceCallNumberAction.putValue(Action.SHORT_DESCRIPTION, null);
myActions = new AbstractAction[] { myResourceNewAction, myResourcePropertiesAction };
}
return myActions;
Expand Down Expand Up @@ -90,6 +94,10 @@ public ResourceSendMailAction getResourceSendMailAction() {
return myResourceSendMailAction;
}

public ResourceCallNumberAction getResourceCallNumberAction() {
return myResourceCallNumberAction;
}

public AssignmentDeleteAction getAssignmentDelete() {
return myAssignmentDelete;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
GanttProject is an opensource project management tool.
Copyright (C) 2011 GanttProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sourceforge.ganttproject.action.resource;

import java.awt.event.ActionEvent;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;

import net.sourceforge.ganttproject.ResourceTreeTable;
import net.sourceforge.ganttproject.action.GPAction;
import net.sourceforge.ganttproject.resource.HumanResource;
import net.sourceforge.ganttproject.util.BrowserControl;

public class ResourceCallNumberAction extends GPAction implements TreeSelectionListener {
private final ResourceTreeTable myTable;

public ResourceCallNumberAction(ResourceTreeTable table) {
super("resource.callnumber");
myTable = table;
setEnabled(false);
table.getTree().getTreeSelectionModel().addTreeSelectionListener(this);
}

@Override
public void valueChanged(TreeSelectionEvent e) {
setEnabled(myTable.getSelectedNodes() != null && myTable.getSelectedNodes().length > 0);
}

@Override
protected String getIconFilePrefix() {
return "call_number_";
}

@Override
public void actionPerformed(ActionEvent e) {
if (myTable.getSelectedNodes() != null && myTable.getSelectedNodes().length > 0) {
HumanResource resource = (HumanResource) myTable.getSelectedNodes()[0].getUserObject();
if (resource != null) {
try {
BrowserControl.displayURL("tel:" + resource.getPhone());
} catch (Exception exception) {
System.err.println(exception);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<td valign="top"><b><xsl:value-of select="name"/></b></td>
<td valign="top"><xsl:value-of select="role"/></td>
<td valign="top"><a><xsl:attribute name="href">mailto:<xsl:value-of select="mail"/></xsl:attribute><xsl:value-of select="mail"/></a></td>
<td valign="top"><xsl:value-of select="phone"/></td>
<td valign="top"><a><xsl:attribute name="href">tel:<xsl:value-of select="translate(phone, ' ', '')"/></xsl:attribute><xsl:value-of select="phone"/></a></td>
</tr>
</xsl:for-each>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<td valign="top"><b><xsl:value-of select="name"/></b></td><td width="1" bgcolor="#002000"/>
<td valign="top"><xsl:value-of select="role"/></td><td width="1" bgcolor="#002000"/>
<td valign="top"><a><xsl:attribute name="href">mailto:<xsl:value-of select="mail"/></xsl:attribute><xsl:value-of select="mail"/></a></td><td width="1" bgcolor="#002000"/>
<td valign="top"><xsl:value-of select="phone"/></td>
<td valign="top"><a><xsl:attribute name="href">tel:<xsl:value-of select="translate(phone, ' ','')"/></xsl:attribute><xsl:value-of select="phone"/></a></td><td width="1" bgcolor="#002000"/>
</tr>
</xsl:for-each>
</table>
Expand Down